How to find all first records of specified item between each specified case in the table
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have the below table, and I want to extract all first records (appear first time after calibration) of "End" after each calibration.
Case1: If the first record after calibration is "End" just extract that row.
Cae2: If the first record after calibration is not "End", and check for the "End" record before next calibration, and take that row (if "End" exist before next calibration)
Case3: If no "End" record exists before next calibration, just take the last record before next calibration.
Kindly help, Many thanks in advance,
Calibration HT0MEK
End HT0MEK
Calibration JT0KEL
Paused T0KEL
End JT0KEL
End JT0KEL
Calibration BK0JIL
Paused HA0GEK
Paused HA0GEK
My output should be: (Row 2, Row 5, and Row 9)
Output:
End HT0MEK
End JT0KEL
Paused HA0GEK
Many thanks in advance
0 个评论
采纳的回答
Azzi Abdelmalek
2016-4-16
编辑:Azzi Abdelmalek
2016-4-16
Edit
v={'Calibration' 'HT0MEK'
'End' 'HT0MEK'
'Calibration' 'JT0KEL'
'Paused' 'T0KEL'
'End' 'JT0KEL'
'End' 'JT0KEL'
'Calibration' 'BK0JIL'
'Paused' 'HA0GEK'
'Paused' 'HA0GEK'
'Calibration' 'HA0GE'}
c1=v(:,1);
idx1=find(ismember(c1,'Calibration' ))
idx1=[ones(size(idx1)) idx1]
idx2=find(ismember(c1,'End' ))
idx2=[2*ones(size(idx2)) idx2]
h=sortrows([idx1;idx2],2)
ii=strfind(h(:,1)',[1 2])+1
ind1=h(ii,2)
jj=strfind(h(:,1)',[1 1])+1
ind2=h(jj,2)-1
ind=sort([ind1;ind2])
out=v(ind,:)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 National Instruments Frame Grabbers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!