How can I sava a series of variables to a txt file?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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');
0 Kommentare
Antworten (1)
Walter Roberson
am 27 Sep. 2013
Have you considered save() with the -ascii flag ?
Beyond that, see
2 Kommentare
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!