MATLAB: Find Vector of Index Without Using Loop

index

Hi all,
If I have
a=[2 3 4 5]
b=[3 5]
%what I want is the index of same elements between a and b, which gives:
i=[2 4]
I want to do this without having to use any loop, because the data is hundreds of thousands elements. Using find() will require me to use loop I think.
Please help. Thanks.

Best Answer

Please try ismember function, like:
[~,idx] = ismember(b,a);