I have a 2D matrix myMatrix
of integers which I want to save its content to a text file. I did the following:
save myFile.txt myMatrix -ASCII
I get this message:
Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'myMatrix' not written to file. and nothing is written.
What to do?
To write myMatrix to myFile.txt:
dlmwrite('myFile.txt', myMatrix);
To read the file into a new matrix:
newMatrix = dlmread('myFile.txt');
You have to convert your matrix to double before using save.
>> myMatrix2 = double(myMatrix);
>> save myFile.txt myMatrix2 -ASCII
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With