How I can find the index when both signals are high?

1 次查看(过去 30 天)
I have two signals. I want to find out indexes on which both signals are high. Both signals have the amplitude (0 & 1). Blue signal is shifted at y=1. Please help me. Thanks

采纳的回答

Bruno Luong
Bruno Luong 2020-8-3
编辑:Bruno Luong 2020-8-3
Assuming your signal are binary vectors of the same size b and r
both = min(b,r);
d = diff([0; both(:); 0]);
upidx = find(d==1) % index where both become high, a & c
downidx = find(d==-1) % index where any of b/r becomes low (so both is no longer high), b & d
lgt = downidx-upidx % (b-a) and (d-c)
  8 个评论
Bruno Luong
Bruno Luong 2020-8-3
编辑:Bruno Luong 2020-8-3
Sorry I give up. Your example is not generic for me, it's even totally trivial as both signal are exactly out of phase to each other. Your "explanation" is then not useful for me.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by