How to import multiple .m files
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is there a simple loop or so to call multiple files and extract the sub structures from it where all .m files have the same substructure?
1 comentario
Star Strider
el 9 de Dic. de 2016
Are you asking about MATLAB script ‘.m’ files or binary ‘.mat’ files?
Respuestas (2)
Park Joohyung
el 9 de Dic. de 2016
I`m answering assuming that you are mentioning '.mat' file. ('.m' file is merely a matlab script file..) If the data you want to load has regular name, like 'name1.mat', 'name2.mat'..., I recommend you to use 'eval' function with for loop.
for i=1:10
eval( ['load(''name' num2str(i) '.mat'')'] );
end
Image Analyst
el 10 de Dic. de 2016
See the FAQ for how to process a bunch of files: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F.
In the middle of the loop, put Stephen's code to store all the structures pulled from your mat files.
matFullFileName = fullfile(pwd, sprintf('name%d.mat',k)); % Whatever.....
S{k} = load(matFullFileName) % Store this file's structure in our structure array.
0 comentarios
Ver también
Categorías
Más información sobre Variables 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!