Variable in a string name
Mostrar comentarios más antiguos
I am reading columns of binary files to plot. I have all my files in one folder and I want to plot them and pull out certain data. How can I set up a loop that will go through all the files?
My idea so far:
1) Use D= dir('W:\Folder')
to retrieve the names of all the files
2) for i= 1:70
str = ('W:\Folder\D(i)\Data')
fid = fopen(str);
How can I insert the different names in the array D from step 1?
I tried sprintf but I believe there is a problem because it's a path.
Thank you for your help
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 23 de Sept. de 2014
Use sprintf() to construct the filename from i.
filename = sprintf('W:/Folder/%s/Data.dat', D(i).name);
See the FAQ for full sample code: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Categorías
Más información sobre File Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!