Borrar filtros
Borrar filtros

sorting vector with duplicated values in it.

2 visualizaciones (últimos 30 días)
Andrea
Andrea el 24 de Ag. de 2012
Hey All,
I have a vector that I want to sort but remove the duplicated values. I know I can do that with "unique"but I need to keep the number of repetitive valuessuch as this: a=[10 1 2 10 1 6 7 8 9 10 8 9 2 3 0];
I want to have 2 outputs like this:
a= [0 1 2 3 6 7 8 9 10];
Number=[1 2 2 1 1 1 2 2 3];

Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Ag. de 2012
unique_a = unique(a);
Number = histc(a, unique_a);
  1 comentario
Andrea
Andrea el 24 de Ag. de 2012
Thanks so much. It is perfect job in just 2 lines!!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by