MATLAB: Load several (one after another ) .mat Files via a For-Loop Job

for looploadmatseveral

Hello, i have a Program that is in the Folder-Directory: Main. And i have some several numbered .mat-Files with the Variable Buff that are in the Folder Directory Main/Combination:
combinations_1.mat
combinations_2.mat
combinations_3.mat
...and so on
My Program should load the first combinations_1.mat and to something:
for I = 1:size(Buff,1)
% calculate some stuff
end
After the Loop is done it should load combinations_2 and start the Loop again
My Idea is:
d = dir('*.mat'); % only looking for .mat-Files
Number_mat = length(d); % number of .mat-Files
for i=1:Number
load(['combinations_' num2str(i) '.mat'])
end
But i no idea how i can this combine with the For-Loop. Hope everybody understand my aim, big thanks

Best Answer

Unless I am missing something, I think the easiest thing would be to do a nested for loop.
for ii = 1: Number
load(['combinations_' num2str(ii) '.mat'])
for jj = 1:size(Buff,1)
% calculate some stuff
end
end
Related Question