how to delete repated rows with out re order them

1 回表示 (過去 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 Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by