Uninterrupted segment length?
显示 更早的评论
Let's say I have an array indexes:
Indexes = [1122221122111211112222222]
How do I get the length of uninterrupted 2s? I want to output to be
output=[ 4 2 1 7]
采纳的回答
更多回答(1 个)
Roger Stafford
2016-11-28
编辑:Roger Stafford
2016-11-28
f = find(diff([false,Indexes==2,false])~=0);
output = f(2:2:length(f))-f(1:2:length(f));
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!