MATLAB: How to find order of the elements in a vector in another vector

MATLAB

Suppose I have a vector A = [1,2,3] and a vector B = [5,2,3,4,1].
How can I find the order of the elements in A in vector B?
For example, the order of elements in A in vector B should be [5, 2, 3] because B(5) = 1, B(2) = 2 and B(3) = 3.

Best Answer

[~, idx] = ismember(A, B)