selecting unique rows

I have an matrix of 6 columns,all columns have repeated numbers,now i want to select only unique values of that matrix ,please help

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 18 de En. de 2012

0 votos

EDIT [23:27(UTC+4) 18.01.2012]
a = [1 2 7 8 9 0
2 2 71 2 4 1];
out0 = a(all(diff(sort(a,2),1,2) > 1e4*eps,2),:)
out1 = sortrows(out0);
loc = [true;all(diff(out1,1,1),2)];
out = out1(loc,:);

1 comentario

kash
kash el 18 de En. de 2012
andrei am not gtting exact result plz look at my file and result
http://www.sendspace.com/file/knqbjv
every column has same values,,i nees only unique values in every column

Iniciar sesión para comentar.

Más respuestas (2)

TAB
TAB el 18 de En. de 2012

0 votos

Type
>> doc unique
on your command window
Wayne King
Wayne King el 18 de En. de 2012

0 votos

C = unique(A,'rows');
Selects the unique rows of the matrix A in sorted order. Is that what you mean?

6 comentarios

kash
kash el 18 de En. de 2012
no wayne not in sorted order,I have 6 columns in that i have many repeating numbers
ex
1 2 7 8 9 0
2 2 71 2 4 1
2 10 3 8 5 0
my matrix has many repeated numbers,1st,2nd 4th,6th,i need only unique values
Wayne King
Wayne King el 18 de En. de 2012
then just unique(A)
kash
kash el 18 de En. de 2012
no wayne i tried this and did not get result
Wayne King
Wayne King el 18 de En. de 2012
I think you need to make your use case clearer, with your above example, show us what you want the output to look like.
kash
kash el 18 de En. de 2012
i my matrix my first column has repeated values
so
1 2 7 8 9 0
2 2 71 2 4 1
now 2nd column has repeating values
si i need as
1 2 7 8 9 0
like this i have 32000 rows and 6 columns
Andrei Bobrov
Andrei Bobrov el 18 de En. de 2012
a = [1 2 7 8 9 0
2 2 71 2 4 1];
out = a(all(diff(sort(a,2),1,2) > 1e4*eps,2),:)

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 18 de En. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by