Find Vector of Index Without Using Loop

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 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

質問済み:

2018 年 4 月 27 日

回答済み:

2018 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by