Effacer les filtres
Effacer les filtres

Garbage values when storing the data into .dat file

1 vue (au cours des 30 derniers jours)
Shashi TG
Shashi TG le 27 Fév 2017
Modifié(e) : Jan le 27 Fév 2017
Hello there, I have a 3D array having data type float. When i store this array into a .txt or .mat file and then open it, it has only random data.
I am using the following command: save('test.txt','x'); Can someone help me?

Réponse acceptée

Jan
Jan le 27 Fév 2017
Modifié(e) : Jan le 27 Fév 2017
What you see is the expected output: The 3D array is writting in binary format to the MAT file. It is not random and after a load() you get back the original data.
What exactly is your question? Do you want to create a text file, which can be read by humen? If so, are you really sure, that you need this? A 3D-array need some reshaping to a 2D-matrix for awriting it to a file. Then the values and the structure is not clear anymore in every case. Therefore I'd suggest to stay at the binary format and use Matlab as a viewer of the data, not Notepad.
  1 commentaire
Stephen23
Stephen23 le 27 Fév 2017
+1 for asking what the point is.

Connectez-vous pour commenter.

Plus de réponses (2)

Walter Roberson
Walter Roberson le 27 Fév 2017
save('test.txt', 'x', '-ASCII')

Shashi TG
Shashi TG le 27 Fév 2017
Hi thanks for reply. It throws me following error:
  1 commentaire
Walter Roberson
Walter Roberson le 27 Fév 2017
Sorry, I overlooked that it is 3D. There is no standard text representation for 3D arrays.
It would be possible to write the array to a .m file as code that would recreate the 3D array. For example it could build all the slides and cat(3) them together.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Standard File Formats dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by