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?

 Akzeptierte Antwort

the cyclist
the cyclist am 20 Feb. 2012

1 Stimme

I think you want the ismember() command.

2 Kommentare

Mateusz
Mateusz am 20 Feb. 2012
Looks exactly what I am looking for, thanks :)
Mateusz
Mateusz am 20 Feb. 2012
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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 20 Feb. 2012

Bearbeitet:

am 17 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by