load multiple .mat files

7 views (last 30 days)
neamah al-naffakh
neamah al-naffakh on 28 Dec 2016
Edited: neamah al-naffakh on 30 Dec 2016
hi everyone,
I have a question.
I am analysing some data which have multiple subjects. Information about every subject is stored in the MATLAB structure (.mat file)
For Example:
and so on...
I would like to create for loop which in every iteration load new data_number.mat file.
I'd like in every iteration to load next .mat file? Particularly, I don't know how to address number part of filename using load function.
I tried this code and seems it's overwritten the data!
for nc = 1:36
load(['U', num2str(nc,'%2d'), '_Acc_TimeD_FreqD_FDay.mat']);
Thank you

Accepted Answer

Walter Roberson
Walter Roberson on 28 Dec 2016
load(['U_', num2str(nc,'%02d'), 'Acc_TimeD_FreqD_FDay.mat']);
load( sprintf('U_%02dAcc_TimeD_FreqD_FDay.mat', nc) );
neamah al-naffakh
neamah al-naffakh on 30 Dec 2016
Edited: neamah al-naffakh on 30 Dec 2016
dear Walter Roberson, many thanks for your help. I really appreciate it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!