In Matlab, I have a cell of which the first column is composed of markers of which there are too many. We want to delete the entire row of the cell of these extraneous markers.
We have four marker types within the first column of our cell - '71', '72', '73' and '74'
: stored as strings. Whenever there is an occurrence of any of these markers, they are repeated ('71'
'72'
23 times and '73'
'74'
16 times). We want to keep the first presentation each time that markers occurs. Then for '71'
'72'
keep every 6th, whereas for '73'
'74'
keep every 4th.
The cell has length 550
so the blocks of 71, 72, 73 and 74
are repeated many times in the cell and there are other markers besides these four present as well that we want to keep.
A small part of the cell is shown below:
'12' 14737 29472
'31' 44747 89492
'4' 44771 89540
'53' 53756 107510
'73' 53831 107660
'73' 54082 108162
'73' 54331 108660
'73' 54582 109162
'73' 56081 112160
'73' 56331 112660
'73' 56581 113160
'73' 56831 113660
'73' 58330 116658
'73' 58580 117158
'73' 58829 117656
'73' 59079 118156
'73' 60579 121156
'73' 60829 121656
'73' 61079 122156
'73' 61329 122656
'63' 351340 702678
'4' 351361 702720
'54' 360342 720682
'74' 360375 720748
'74' 360633 721264
'74' 360883 721764
'74' 361133 722264
'74' 362632 725262
'74' 362882 725762
'74' 363132 726262
'74' 363382 726762
'74' 364881 729760
'74' 365131 730260
'74' 365381 730760
'74' 365631 731260
'74' 367130 734258
'74' 367380 734758
'74' 367630 735258
'74' 367880 735758
'64' 369374 738746
'4' 369379 738756
'51' 378376 756750
'71' 378409 756816
'71' 378584 757166
'71' 378750 757498
'71' 378917 757832
**continued**
I'm not sure how to do this, I tried to use indices to approach this problem but have so far been unsuccessful.
Could anyone help?
Thanks
What I've tried so far:
function Y = correctRows(y)
Y.type = {};
Y.latency = [];
Y.latency_ms = [];
for i = 1:length(y)
if strcmp(y(i).type,'71') || strcmp(y(i).type,'72')
Y(i) = y(i);
i = i+5;
elseif strcmp(y(i).type,'73') || strcmp(y(i).type,'74')
Y(i) = y(i);
i = i+3;
else
Y(ii) = y(i);
end
end