Opening/loading multiple mat files?

조회 수: 2 (최근 30일)
Ibro Tutic
Ibro Tutic 2016년 3월 22일
댓글: Ibro Tutic 2016년 3월 22일
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?

답변 (2개)

Matthew Eicholtz
Matthew Eicholtz 2016년 3월 22일
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
Matthew Eicholtz
Matthew Eicholtz 2016년 3월 22일
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
Ibro Tutic 2016년 3월 22일
Perfect, I actually was trying to figure out how to combat that, thanks!.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2016년 3월 22일
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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by