How can i find the index of specific value inside an array?

조회 수: 45 (최근 30일)
Gn Gnk
Gn Gnk 2020년 6월 15일
댓글: Gn Gnk 2020년 6월 15일
I have an array lets say 1x4 with these values : [ 2 4 6 8 ] .How can i find the index that 4(index 2 of the array) is stored for example and then save it to some variable?

채택된 답변

Gn Gnk
Gn Gnk 2020년 6월 15일
index=find(M==4) % M=[2 4 6 8];
returns the index 2 i wanted
  댓글 수: 2
madhan ravi
madhan ravi 2020년 6월 15일
Isn’t that what I answered?
Gn Gnk
Gn Gnk 2020년 6월 15일
Yes , i indeed searched find .I just wanted to give a detailed solution for anyone who has the same problem.

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

추가 답변 (1개)

madhan ravi
madhan ravi 2020년 6월 15일

카테고리

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