Finding islands of zeros in a sequence

后端 未结 6 510
小蘑菇
小蘑菇 2020-11-22 14:05

Imagine you have a very long sequence. What is the most efficient way of finding the intervals where the sequence is all zeros (or more precisely the sequence drops to near-

6条回答
  •  迷失自我
    2020-11-22 14:45

    I think the most MATLAB/"vectorized" way of doing it is by computing a convolution of your signal with a filter like [-1 1]. You should look at the documentation of the function conv. Then on the output of conv use find to get the relevant indexes.

提交回复
热议问题