Removing duplicates of rows from a matrix (finding and removing combination duplicates)
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Monica W
el 13 de Mzo. de 2021
Comentada: Monica W
el 14 de Mzo. de 2021
I have a 12x3 double matrix and I want to identify duplicates of combinations of the same numbers and then produce a matrix containing the rows minus those duplicates (e.g. remove 2 as it is a duplicate of combo 1).

How can I go about this?
0 comentarios
Respuesta aceptada
Walter Roberson
el 13 de Mzo. de 2021
[~, ia] = unique(sort(YourMatrix, 2),'rows', 'stable');
NewMatrix = YourMatrix(ia,:);
Although the sort() changes the order of the columns, I go back to the original for the indexing. So for example if the first row had been [5 3 4] then the first row of output would be [5 3 4]... just in case that was important to you.
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!