필터 지우기
필터 지우기

Conditional find in matlab

조회 수: 4 (최근 30일)
Amir Mahmoudi
Amir Mahmoudi 2024년 1월 18일
댓글: Les Beckham 2024년 1월 18일
I = find(X == a,1,'first'), J = find(X == b,1,'first'), K = find(X == c,1,'first') provided that K > J > I How can I implement the conditional part? Thanks in advance.

채택된 답변

Les Beckham
Les Beckham 2024년 1월 18일
편집: Les Beckham 2024년 1월 18일
X = [10 20 30 40 50 10 20 30 40 50];
a = 30;
b = 20;
I = find(X == a, 1, 'first')
I = 3
J = find(X((I+1):end) == b, 1, 'first') + I % start search after index I
J = 7
X(I)
ans = 30
X(J)
ans = 20
  댓글 수: 2
Amir Mahmoudi
Amir Mahmoudi 2024년 1월 18일
Is it possible to write your codes in terms of > or < ?
Les Beckham
Les Beckham 2024년 1월 18일
Sure, just change the == to whatever you want instead.

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

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