Deleting duplicate values in matrix

1 visualización (últimos 30 días)
kash
kash el 27 de Ag. de 2012
I have a dataset in which i have duplicate vaues(same values),i want to delete it as
S={
'' 'c1' 'c2' 'c3'
'p-a' 'pso' 'mpso' 'pso'
'p-a' 'pso' 'mpso' 'pso'
'p-a' 'pso' 'mpso' 'pso'
'k' 'spsp' 'pso' 'mpso'
'y-b' 'pso' 'pso' 'spso'
'y-b' 'pso' 'pso' 'spso'}
i need output as
out={
'p-a' 'pso' 'mpso' 'pso'
'k' 'spsp' 'pso' 'mpso'
'y-b' 'pso' 'pso' 'spso'}
please help
  1 comentario
Jan
Jan el 27 de Ag. de 2012
Why does the first row vanish?

Iniciar sesión para comentar.

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 27 de Ag. de 2012
[trash,idx] = unique(S(:,1),'stable');
S(idx,:)
Note that only the first column is considered to be the key.
  6 comentarios
Andrei Bobrov
Andrei Bobrov el 27 de Ag. de 2012
[trash,idx] = unique(S(:,1),'first');
out = S(sort(idx),:);
kash
kash el 29 de Ag. de 2012
Thanks andrei and Jan by mistake i clicked Accepy the answer button

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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