Extracting column no. from an array based on values in another array

Hi,
I have an array: Array1
and another array(sub set of above one): Array2
I want to know the position of elemnts of Array2 in Array1.
For Ex:
Input:
Array1 - [A,B,C,D,E,F]
Array2 - [B,D]
Output:
2,4

 採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 11 月 21 日
編集済み: Andrei Bobrov 2017 年 11 月 21 日

1 投票

Use ismember
Array1 = {'A','B','C','D','E','F'}
Array2 = {'B','D'}
[~,ii] = ismember(Array2,Array1)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2017 年 11 月 21 日

コメント済み:

2017 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by