How can I sava a series of variables to a txt file?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 27 Sep 2013
Have you considered save() with the -ascii flag ?
Beyond that, see
2 commentaires
Voir également
Catégories
En savoir plus sur String Parsing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!