How to look for a list insto an other list

1 回表示 (過去 30 日間)
Gimpy
Gimpy 2014 年 8 月 5 日
回答済み: Sean de Wolski 2014 年 8 月 5 日
Hi, I have the following list:
lookfor={'ab' 'cd' 'ef' 'ab' 'cd''gh' 'ij' 'ab' 'cd'}
into={'ab' 'cd' 'ef' 'gh' 'ij'}
I would like to know the colunm number for each element in "into" reults: [1 2 3 1 2...]

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 8 月 5 日
lookf={'ab' 'cd' 'ef' 'ab' 'cd' 'gh' 'ij' 'ab' 'cd'}
into={'ab' 'cd' 'ef' 'gh' 'ij'}
[~, idx] = ismember(into,lookf)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by