Find Vector of Index Without Using Loop

1 次查看(过去 30 天)
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.

采纳的回答

Akira Agata
Akira Agata 2018-4-27
Please try ismember function, like:
[~,idx] = ismember(b,a);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by