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

35 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by