Remove duplicate rows from matrix

61 visualizaciones (últimos 30 días)
MC
MC el 14 de Mayo de 2017
Editada: Stephen23 el 6 de Mzo. de 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 comentarios
Garvit Amipara
Garvit Amipara el 6 de Mzo. de 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 el 6 de Mzo. de 2022

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 14 de Mayo de 2017
Editada: Stephen23 el 14 de Mayo de 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 comentarios
LO
LO el 12 de Abr. de 2019
how can I keep all values of each row ?
Paween Pongsomboon
Paween Pongsomboon el 18 de Feb. de 2022
I don't know if you still alive, stephen. I wish I could hug you now!
Thx for the super solution

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by