Find elements of a vector

1 visualización (últimos 30 días)
Tom
Tom el 12 de Feb. de 2014
Comentada: Azzi Abdelmalek el 12 de Feb. de 2014
If I have a vector, e.g.
A = [ 2 8 6 5 3 3 6 5 5 3 4 1 2 9 6]
How do I return a vector which just gives single examples of the elements of A, e.g.
B = [1 2 3 5 6 8 9]
Kind regards,
Tom

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 12 de Feb. de 2014
Editada: Azzi Abdelmalek el 12 de Feb. de 2014
B=unique(A)
You can make the result without sorting
B=unique(A,'stable')
  6 comentarios
Tom
Tom el 12 de Feb. de 2014
Sorry.
If I have a vector e.g.: B = [1 2 3 5 6 8 9]
I want to look through the elements of B
i.e. I tried:
for j = B
do something
end
But this doesn't seem to work...
Azzi Abdelmalek
Azzi Abdelmalek el 12 de Feb. de 2014
That's depends on what (do something) is

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical 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