Finding indices when vectors is used

조회 수: 1 (최근 30일)
Mateusz
Mateusz 2012년 2월 20일
편집: Matt J 2013년 10월 17일
Assume we have x = [1,2,3,1]; If I execute idx = find(x == 1) then idx == [1,4]. Is there similar command for extracting more indices I am interested in, something like find(x == [1,3]) == [1,3,4].
Of course I would like to avoid loops.
-- Ok, but what if we allow repetitions? For instance: find(x == [1,3,1]) == [1,1,3,4,4] Can we do this without using loops?

채택된 답변

the cyclist
the cyclist 2012년 2월 20일
I think you want the ismember() command.
  댓글 수: 2
Mateusz
Mateusz 2012년 2월 20일
Looks exactly what I am looking for, thanks :)
Mateusz
Mateusz 2012년 2월 20일
Ok, but what if we allow repetitions? For instance: find(x == [1,3,1]) == [1,1,3,4,4] Can we do this without using loops?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by