MATLAB: Getting intersected index without ruining an order of the original data.

addressarrayindexintersectmatrixreference

Assuming that, A=[1234 345 675 11 2], and B=[345 2 11 2]
Don't know how to get a reference matrix from B to A as like ans=[2 5 4 5]

Best Answer

Use the ismember function:
A=[1234 345 675 11 2];
B=[345 2 11 2];
[~,C] = ismember(B,A)
C =
2 5 4 5
Related Question