Borrar filtros
Borrar filtros

select some component of vector

6 visualizaciones (últimos 30 días)
zina ben
zina ben el 27 de Jun. de 2012
Comentada: Juan Andrés Meza Silva el 20 de Mayo de 2021
Hello!
i think i chose the wrong example last time
I have this vector:
V = [12 45 30 4 56 79 8 94 55]';
i need just to used
V1 = [79 8 94 ]
the component numb 6 , 7 and 8
what can i do
please help me. Thanks in advance

Respuestas (1)

the cyclist
the cyclist el 27 de Jun. de 2012
If you have inputs V and V1, and you are looking for the output to be [6 7 8], then you want
out = find(ismember(V,V1));
If you have inputs V and [6 7 8], and you are looking for the output to be V1, then you want
out = V([6 7 8])
or
out = V(6:8)
  2 comentarios
Walter Roberson
Walter Roberson el 27 de Jun. de 2012
An approach without using find() is
[tf, out] = ismember(V, V1);
Juan Andrés Meza Silva
Juan Andrés Meza Silva el 20 de Mayo de 2021
THANK U IN CAPS.

Iniciar sesión para comentar.

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by