Remove duplicate rows from matrix

7 vues (au cours des 30 derniers jours)
MC
MC le 14 Mai 2017
Modifié(e) : Stephen23 le 6 Mar 2022
Hello
I have a 2xN matrix where each column represent the x and y coordinates of a 2D point. I need to remove any duplicate point from this matrix, any suggestions?
Best regards MC
  4 commentaires
Garvit Amipara
Garvit Amipara le 6 Mar 2022
It would be very nice of you, if you could change the title of this question, it misleads others who are actually looking for the answers related to 'vector'. Thank you(:
Stephen23
Stephen23 le 6 Mar 2022

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 14 Mai 2017
Modifié(e) : Stephen23 le 14 Mai 2017
It is trivial to use unique to get only the unique rows of matrix. Because your matrix is arranged 2xN, simply transpose before and after:
unique(M.','rows').'
  5 commentaires
LO
LO le 12 Avr 2019
how can I keep all values of each row ?
Paween Pongsomboon
Paween Pongsomboon le 18 Fév 2022
I don't know if you still alive, stephen. I wish I could hug you now!
Thx for the super solution

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by