Find number in vector

조회 수: 26 (최근 30일)
Io7
Io7 2023년 1월 21일
댓글: Image Analyst 2023년 1월 21일
Let’s say I have this vector: A = [1,2,3,4,5,6] and I want to know when did my vector went above 3. Like I want to know the value that made my vector go above 3. So I’m interested in the value “4” not 5 or 6. Is there is a code that can help me ?

채택된 답변

Jonas
Jonas 2023년 1월 21일
find(A>3,1)
  댓글 수: 1
Image Analyst
Image Analyst 2023년 1월 21일
This gives the index, not the value. To see the value, see my answer below where I give both the index and the value of the vector at that index.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2023년 1월 21일
Try this:
A = [1,2,3,40,50,60];
index = find(A > 3, 1, 'first')
index = 4
theValueThere = A(index)
theValueThere = 40

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by