how to delete repated rows with out re order them

조회 수: 2 (최근 30일)
Jwana
Jwana 2012년 12월 17일
Hi all,
I have this cells arrays:
levelx=
'GO:0016787' 'GO:0006412' 'GO:0030533'
'GO:0008150' 'GO:0006412' 'GO:0030533'
'GO:0006810' 'GO:0006412' 'GO:0030533'
'GO:0016787' 'GO:0006412' 'GO:0030533'
'GO:0008150' 'GO:0006412' 'GO:0030533'
'GO:0006810' 'GO:0006412' 'GO:0030533'
'GO:0016787' 'GO:0006412' 'GO:0030533'
'GO:0008150' 'GO:0006412' 'GO:0030533'
'GO:0006810' 'GO:0006412' 'GO:0030533'
'GO:0016787' 'GO:0006412' 'GO:0030533'
I need to delete the repeated rows but without changing the order of the whole rows... note that I used a code that find te unique rows but it change the order of the rows:
[~,idx]=unique(cell2mat(levelx),'rows');
unique_levelx = levelx(idx,:);

채택된 답변

José-Luis
José-Luis 2012년 12월 17일
[~,idx]=unique(cell2mat(levelx),'rows','first');
unique_levelx = levelx(sort(idx),:);

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 12월 17일
out = unique(levelx,'rows','stable');
  댓글 수: 2
Jan
Jan 2012년 12월 17일
Assuming that a very modern Matlab version is used.
Andrei Bobrov
Andrei Bobrov 2012년 12월 17일
Hi Jan!
Yes, R2012a and later.

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

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by