MATLAB Answers

0

Uploading multiple matfiles from same folder.

Asked by Muhammad Haziq on 22 May 2019
Latest activity Commented on by Muhammad Haziq on 23 May 2019
Hi,
I want to upload multiple .mat files from a folder and want to save their data in variables. can any body guide me how can I do that. The initial names of the .mat files are different but last name is same.

  1 Comment

Is there any pattern in the names? Could you edit the question with 5 file names or so?

Sign in to comment.

Tags

Products


Release

R2018a

1 Answer

Answer by KALYAN ACHARJYA on 22 May 2019
Edited by KALYAN ACHARJYA on 22 May 2019
 Accepted Answer

Make folder as currnt working directory
list=dir('*.mat');
for j=1:length(list)
matfile=load(list(j).name);
% do operation....one and next loop iterattion it load other
end
or if you want to load all mat files as cell array
use
matfile{j}=load(list(j).name);

  1 Comment

Thanks, it work well

Sign in to comment.