MATLAB how to automatically read a number of files
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to plot a number of 3D graphs from different data files. For example I am using
fid = fopen('SS 1.dat','r');
to read the first file and then plot a graph. How to set the program to change the name to 'SS 2.dat' automatically? Also for the tenth file the name becomes 'SS 10.dat' which has one space less (i.e.only two space between SS and 10) then the first to ninth files. How to set the program to adjust for that? Thank you.
0 Commenti
Risposte (1)
Stephen23
il 29 Ott 2015
Modificato: Stephen23
il 30 Ott 2015
This is a very common question, so we covered it very thoroughly in our wiki:
Because the files already exist I would recommend that you use the dir method, rather than trying to recreate the filenames using sprintf. You can use my FEX submission to sort the filenames correctly:
Or alternatively using sprint you can adapt this for your code:
>> fmt = 'SS%4d.dat';
>> sprintf(fmt,9)
ans = SS 9.dat
>> sprintf(fmt,10)
ans = SS 10.dat
0 Commenti
Vedere anche
Categorie
Scopri di più su Printing and Saving in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!