In/out signal from vector

조회 수: 1 (최근 30일)
Cary
Cary 2016년 4월 9일
댓글: Azzi Abdelmalek 2016년 4월 9일
Imagine I have the following vector:
0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1
The signal from the vector should be interpreted as follows: In at the 6th element, out at the 9th, in again at the 11th element, back out at the 17th, and finally back in at the 19th element through the end. What branch of code should I be using to tell me to get in at 6,11,19 and get out at 9,16?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 9일
편집: Azzi Abdelmalek 2016년 4월 9일
v=[0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1]
ii1=strfind(v,[0 1])+1
ii2=strfind(v,[1 0])+1
%or
ii1=strfind([0 v],[0 1])
ii2=strfind([v 0],[1 0])
  댓글 수: 2
Cary
Cary 2016년 4월 9일
Thanks Azzi! One more question...what if this was a column vector?
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 9일
transpose it

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by