Azzera filtri
Azzera filtri

Finding indices when vectors is used

2 visualizzazioni (ultimi 30 giorni)
Mateusz
Mateusz il 20 Feb 2012
Modificato: Matt J il 17 Ott 2013
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?

Risposta accettata

the cyclist
the cyclist il 20 Feb 2012
I think you want the ismember() command.
  2 Commenti
Mateusz
Mateusz il 20 Feb 2012
Looks exactly what I am looking for, thanks :)
Mateusz
Mateusz il 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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by