MATLAB how to automatically read a number of files
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Stephen23
el 29 de Oct. de 2015
Editada: Stephen23
el 30 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!