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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by