how to delete repated rows with out re order them

2 次查看(过去 30 天)
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');

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by