I'd go at this differently...
ROOTDATADIR='MATLAB/matlab 2023/data/'; % separate out the data from the code
PATIENTFILE='Patient_5'; % select the particular patient wanted
d=dir(fullfile(ROOTDATADIR,PATIENTFILE,'*ictal*.mat')); % get the list of both _ictal & _interictal files
for i=1:numel(d) % and walk through it...
load(fullfile(d(i).folder,d(i).Name)) % then load each in turn...
.... do whatever with each here ... can include test for whether is _inter or not, etc., etc., ...
end
