Hello, I am trying to load some .mat files and run some specific commands on. The .mat files are named as the following:
% Data Files
dataset1_1.mat dataset2_1.mat dataset3_1.mat ...and so ondataset1_2.mat dataset2_2.mat ...and so ondataset1_3.mat ...and so on ...and so on
I want to first load all the dataset1_*.mat files and then perform some calculations on each of them in order (i.e. perform calculations on dataset1_1.mat, then dataset1_2.mat…and so on).
After completing all of the dataset1_*.mat files, I would like to move onto the next batch of files, dataset2_*.mat, and repeat(i.e. perform calculations on dataset2_1.mat, then dataset2_2.mat…and so on).
Process will continue until the last dataset*_*.mat file.
Here is my code so far
% code
files = dir('dataset*_1.mat');for i = length(files) files2 = dir('dataset(i)_*.mat'); for j = 1:length(files2) a = load(files2(j).name); %Perform some calculations on dataset
endend
I am using 2 for loops, not sure where I am going wrong. Thanks for the help!
Best Answer