How can I sava a series of variables to a txt file?
Show older comments
Hi all,
I have a huge series of variables in the matlab workspace. Below you'll find an example of how one of these variables looks like. The problem comes when I want to save all of them to a single textfile. The code below works, although I know there must be a more elegant and faster way to do is. Note that some variables are missing (data3, data5 and data6).
Can someone please help me?
data1 = [297.08,29.54,80.75];
fid = fopen('alldata.txt','w');
fprintf(fid,'%d\t%d\t%d\n',data1');
fprintf(fid,'%d\t%d\t%d\n',data2');
fprintf(fid,'%d\t%d\t%d\n',data4');
fprintf(fid,'%d\t%d\t%d\n',data7');
Answers (1)
Walter Roberson
on 27 Sep 2013
0 votes
Have you considered save() with the -ascii flag ?
Beyond that, see
Categories
Find more on Variables 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!