Find consecutive ones and save the contents

2 views (last 30 days)
Hi,
indcol1 = ind(:,1); % the indexes
indcol2 = ind(:,2); % the array of 1 and 0
Thank you in advance!

Accepted Answer

David Hill
David Hill on 17 Mar 2022
s=num2str(ind6(:,2)');
s=s(s~=' ');
[Start,End]=regexp(s,'[1]{2,}');
for k=1:length(Start)
c{k}=ind6(Start(k):End(k),1)';
end

More Answers (1)

Matt J
Matt J on 17 Mar 2022
Edited: Matt J on 17 Mar 2022
Download this,
Then,
G=groupTrue(indcol2==1);
vars=groupFcn(@(g){g},indcol1, G)

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!