Opening/loading multiple mat files?
Mostrar comentarios más antiguos
I know how to open multiple mat files, using
filename = uigetfile('*.*', 'All Files (*.*)','MultiSelect','on');
But this returns a cell array with the file names that I selected. How would I access these files names for the information stored within them?
Respuestas (2)
Matthew Eicholtz
el 22 de Mzo. de 2016
load(filename{1}); %to load the contents of the first file
load(filename{2}); %to load the contents of the second file
...
%and so on
4 comentarios
Ibro Tutic
el 22 de Mzo. de 2016
Matthew Eicholtz
el 22 de Mzo. de 2016
Yes, a for-loop can work well here. I was simply demonstrating the syntax of calling the load function.
Matthew Eicholtz
el 22 de Mzo. de 2016
One thing to be careful of, however, is if files have similar variables. For instance, if two files have the variable x, then after running the for-loop, you will only have the value(s) for x of the last file that was loaded. To combat this issue, consider using
data{n} = load(filename{n});
or something similar to store the data.
Ibro Tutic
el 22 de Mzo. de 2016
Image Analyst
el 22 de Mzo. de 2016
0 votos
One of our most FA'ed FAQ questions. See the second code sample in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Categorías
Más información sobre Startup and Shutdown 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!