Finding ALL the indicies that match a certain value
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Star Strider
on 10 Dec 2018
Use the find function:
A = 4;
B = [ 3 5 4 6 4 6 7 ];
idx = find(B == A)
producing:
idx =
3 5
0 Comments
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!