Creating for loop with an if statement
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have 100 data files, 50 of the files are of one set named interictal going from 1-50 and the other 50 named ictal also going from 1-50. I am trying to load the first 50 of interictal then 50 of the ictal after. I am trying to load both in one for loop and am struggling to do so. With my code so far I am able to load all 50 of the interictal but after that it loads one ictal then tries to load interictal 51 which it cannot as it doesnt exist. any help would be much appreciated.
s=100
H=zeros(1,s)
for segment=1:s
if segment==50
filename=['MATLAB/matlab 2023/data/Patient_5_ictal_segment_',num2str(segment),'.mat']
load(filename)
end
filename=['MATLAB/matlab 2023/data/Patient_5_interictal_segment_',num2str(segment),'.mat']
load(filename)
end
0 comentarios
Respuestas (1)
dpb
el 2 de Ag. de 2023
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
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!