i would use
H = [0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 0 0]; Hstr=erase(num2str(H),' '); [~,onesEnds]=regexp(Hstr,{'0000+','1111+'}); sort(cell2mat(onesEnds))
i would use
H = [0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 0 0]; Hstr=erase(num2str(H),' '); [~,onesEnds]=regexp(Hstr,{'0000+','1111+'}); sort(cell2mat(onesEnds))
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!