i have 1x1008 struct array eeg.event fields
latency duration channel bvtime bvmknum type code urevent i want delete rows entry in field eeg.event.type = 'boundary' or 'r 1'
i tried following loop:
for b = 1:length(eeg.event) if strcmp(eeg.event(b).type, 'boundary') eeg.event(b) = []; elseif strcmp(eeg.event(b).type, 'r 1') eeg.event(b) = []; end end this not work of course, since counting variable b @ point exceeds length of eeg.event.
does have idea how delete particular rows?
the fundamental issue having modifying same array of structs trying loop through. bad idea , lead issue seeing.
the easiest way convert event.type fields of structs cell array, , use strcmp on of them simultaneously construct logical matrix can use index eeg.event entries care about.
you can put of type values in cell array this
types = {eeg.event.type}; then create logical array looking event types of 'boundary'
isboundary = strcmp(types, 'boundary'); and subset of eeg.event entries this.
boundaryevents = eeg.event(isboundary); if want subset of events type isn't 'boundary' or 'r 1', can subset way.
isboundary = strcmp(types, 'boundary'); isr1 = strcmp(types, 'r 1'); % keep entries aren't boundary or r1 types events_to_use = eeg.event(~(isboundary | isr1));
Comments
Post a Comment