how to delete repated rows with out re order them

2 vues (au cours des 30 derniers jours)
Jwana
Jwana le 17 Déc 2012
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,:);

Réponse acceptée

José-Luis
José-Luis le 17 Déc 2012
[~,idx]=unique(cell2mat(levelx),'rows','first');
unique_levelx = levelx(sort(idx),:);

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 17 Déc 2012
out = unique(levelx,'rows','stable');
  2 commentaires
Jan
Jan le 17 Déc 2012
Assuming that a very modern Matlab version is used.
Andrei Bobrov
Andrei Bobrov le 17 Déc 2012
Hi Jan!
Yes, R2012a and later.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by