opon = stim(:,1); opoff = stim(:,2); % stim on off times scn = stim(:,3); % number of stim wavelengths sint = stim(:,4); % stim intensity for each epoch ilvl = unique(sint); % unique stim intensitites inum = length(ilvl); % number of different stim intensitites ontim = cell(1,inum); offtim = ontim; opfr = ontim; for oi = 1:inum curint = ilvl(oi); curidx = find(sint == curint); ontim{oi} = opon(curidx); offtim{oi} = opoff(curidx); for oti = 1:length(curidx) optmp = (ontim{oi}(oti)*3):(offtim{oi}(oti)*3); opfr{oi} = [opfr{oi} optmp]; end end