Looking for indices of multiple elements in a matrix?

I have an array of elements and I want to see their indices inside another matrix

For example, for

A = [1 2 3] B = [1 2 3 4 5 3 4 5 1 2 3] 

then an array of results

 C = [1 2 3 6 9 10 11] 

which give indices 1 2 3

Is there any function or short way to handle it?

+4
source share
1 answer

I think you want:

 find(ismember(B, A)) ans = 1 2 3 6 9 10 11 
+6
source

All Articles