Effacer les filtres
Effacer les filtres

How to delete duplicate row? unique is not working?

1 vue (au cours des 30 derniers jours)
Ahmed Hamed
Ahmed Hamed le 3 Août 2016
Commenté : Stephen23 le 4 Août 2016
I have a matrix (in the attachment) that contains duplicated rows. I issued this command
spMBL = unique(spMBL, 'rows');
However, this doesn't delete the duplicated row
Any suggestions
  1 commentaire
Stephen23
Stephen23 le 4 Août 2016
Ever row is different:
>> all(any(diff(sortrows(spMBL),1,1),2))
ans = 1
and so unique gives the correct output.

Connectez-vous pour commenter.

Réponse acceptée

Bekay.Kang
Bekay.Kang le 4 Août 2016
Modifié(e) : Walter Roberson le 4 Août 2016
% here's code!
[~,idx]=unique(spBML,'rows')
spBML_new=spBML(sort(idx),:)
:)

Plus de réponses (1)

Walter Roberson
Walter Roberson le 4 Août 2016
spMBL = unique(spMBL, 'rows');
does work. The result has every row different than every other row. In the rows I examined, in each case row spMBL(J,:) is different than spMBL(J+1,:) in position size(spMBL,2)-J+1 . For example, size(spMBL,2) is 312, and spMBL(88,:) is different from spMBL(89,:) in position #312-88+1 = 225, so spMBL(88,225) is not equal to spMBL(89,225)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by