How to find out all array element indices equal to several values (>2)
For example, I have an array a=[1 2 3 4 5 5 4 3 2 2 2 1]
, I want to know the indices of all elements equal to b=[2 5]
Remember, I cannot use style like a==b(1) | a==b(2)
because number of elements in b is arbitrary.
Do I have to use a for loop to do this?