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

36 次查看(过去 30 天)
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

更多回答(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