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

조회 수: 1 (최근 30일)
Tehreem Syed
Tehreem Syed 2020년 8월 3일
댓글: Tehreem Syed 2020년 8월 3일
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.
Tehreem Syed
Tehreem Syed 2020년 8월 3일
Ok Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (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