Finding ALL the indicies that match a certain value

3 次查看(过去 30 天)
Suppose I have a variable A= 4
and I have a vector B = [ 3 5 4 6 4 6 7 ]
I want to find the index of B that match A
that is , a vector with [ 3 , 5 ] since they are the third and 5th

回答(1 个)

Star Strider
Star Strider 2018-12-10
Use the find function:
A = 4;
B = [ 3 5 4 6 4 6 7 ];
idx = find(B == A)
producing:
idx =
3 5

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by