Extract elements of a list using their indices

6 ビュー (過去 30 日間)
Izem
Izem 2020 年 8 月 27 日
コメント済み: Star Strider 2020 年 8 月 27 日
I have a list B which contains the indices of a classified elements and a bigger list A and I want to extract the elements of A using the indices in the list A.
Is there a simple way to do it ?
NB :
I used this line to get theses indices :
[sharedvals,idx] = intersect(A,B,'stable');
Thank you in advance for your answers.

採用された回答

Star Strider
Star Strider 2020 年 8 月 27 日
The ‘sharedvals’ result should be what you want, however it returns the identified values without repitition. If you want all of them (asuming there are more than one of some of them), the ismember function might be more appropriate.
Note that more information would be helpful, including the reason you asked this, considering that intersect appears to do what you want.
  4 件のコメント
Izem
Izem 2020 年 8 月 27 日
Okay thank you !
Star Strider
Star Strider 2020 年 8 月 27 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by