How do I get an ASCII file with the variable names and values of variables I have saved in a binary MAT-file in MATLAB 7.6 (R2008a)?
6 views (last 30 days)
Show older comments
I am trying to get an ASCII file with both the names and values of the variables in my MATLAB workspace. I have tried using the SAVE command as shown in the following example, however the resulting ASCII file only shows the variable values, not the variable names. I would like both to show up.
z1 = 1;
z2 = 3;
z3 = 20;
save filename1 z* -ascii
Accepted Answer
MathWorks Support Team
on 2 Sep 2009
The ability to get both the variable names and variable values into an ASCII file using the SAVE command is not available in MATLAB 7.6 (R2008a).
To work around the issue, it is possible to read the variable names and values from a MAT-file and print them to an ASCII text file. Download the attached file 'createAsciiFile' and try the following example:
z1 = 3;
z2 = 20;
z3 = 13;
save foofile.mat z*
createAsciiFile('foofile.mat');
'createAsciiFile' will create a text file with the same name as the MAT-file, so in this example, it will create 'foofile.txt'.
0 Comments
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!