Finding the start and end indices of 3 or more repeating 0's.
1 次查看(过去 30 天)
显示 更早的评论
For the array A=[NaN NaN NaN NaN 0 0 0 NaN NaN 0 0 0 0 NaN NaN 0 0]
I need to find the start and end indices of the '0' runs with greater than or equal to 3 zeroes in a row.
So for A, the values I want returned are [5 7;10 13].
0 个评论
采纳的回答
Azzi Abdelmalek
2014-2-7
A=[NaN NaN NaN NaN 0 0 0 NaN NaN 0 0 0 0 NaN NaN 0 0]
ii=A==0
ii1=strfind([0 ii 0],[0,1])
ii2=strfind([0 ii 0],[1,0])-1
idx=ii2-ii1+1>=3
out=[ii1(idx)' ii2(idx)']
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!