Effacer les filtres
Effacer les filtres

How can i delete repeated rows?

1 vue (au cours des 30 derniers jours)
Ahmed Hamed
Ahmed Hamed le 3 Août 2016
Modifié(e) : Guillaume le 3 Août 2016
I have a matrix A as follows
A = 1,1,2,3,4
2,1,2,3,4
I'd like to consider that the two rows are identical as the firs column only describes the index, so the output should like
A = 1,1,2,3,4
or
A= 2,1,2,3,4
when I make use of unique(A,'rows') it doesn't consider the two rows are identical
Any help, please.

Réponse acceptée

Guillaume
Guillaume le 3 Août 2016
Modifié(e) : Guillaume le 3 Août 2016
Use the second return value of unique:
[~, rowstokeep] = unique(A(:, 2:end), 'rows');
newA = A(rowstokeep, :)

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and 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