Borrar filtros
Borrar filtros

Finding indices when vectors is used

2 visualizaciones (últimos 30 días)
Mateusz
Mateusz el 20 de Feb. de 2012
Editada: Matt J el 17 de Oct. de 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?

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by