selecting unique rows

조회 수: 5 (최근 30일)
kash
kash 2012년 1월 18일
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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 1월 18일
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
kash
kash 2012년 1월 18일
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

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

TAB
TAB 2012년 1월 18일
Type
>> doc unique
on your command window

Wayne King
Wayne King 2012년 1월 18일
C = unique(A,'rows');
Selects the unique rows of the matrix A in sorted order. Is that what you mean?
  댓글 수: 6
kash
kash 2012년 1월 18일
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 2012년 1월 18일
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),:)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by