MATLAB Answers

Finding ALL the indicies that match a certain value

1 view (last 30 days)
Abbi Hashem
Abbi Hashem on 10 Dec 2018
Answered: Star Strider on 10 Dec 2018
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

Sign in to comment.

Answers (1)

Star Strider
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

Sign in to comment.

Tags