"Possibly what is the error, it says that File doesn't exist."
Most likely the files do not exist in the location where you are trying to read them from, or the filenames are incorrect.
For example, your first example name starts with "Sub1..." but at the start of your code you have a cell array named Subjects where the first name is "Sub 01". Those are two very different name formats. No one here can tell you which one is correct. You have to know exactly what the name format is, and create names that match them exactly.
I wouldn't use a loop for the sessions, just the subjects. Perhaps something like this:
P = 'path to the folder where the files are saved';
N = total number of subjects;
for k = 1:N
F1 = fullfile(P,sprintf('Sub%u_S1_Epochs.mat',k));
F2 = fullfile(P,sprintf('Sub%u_S2_Epochs.mat',k));
S1 = load(F1);
S2 = load(F2);
end
Best Answer