How to look for a list insto an other list

1 Ansicht (letzte 30 Tage)
Gimpy
Gimpy am 5 Aug. 2014
Beantwortet: Sean de Wolski am 5 Aug. 2014
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...]

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 5 Aug. 2014
lookf={'ab' 'cd' 'ef' 'ab' 'cd' 'gh' 'ij' 'ab' 'cd'}
into={'ab' 'cd' 'ef' 'gh' 'ij'}
[~, idx] = ismember(into,lookf)

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by