How to identify the repeated elements in an array and delete those rows?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a matrix array like this:
1 100
2 200
3 200
4 200
5 500
And I want to identify the repeated elements on the right column, and delete the entire row of the matrix, to get something like this:
1 100
2 200
5 500
How can I do that?
0 comentarios
Respuestas (2)
the cyclist
el 9 de Abr. de 2023
Editada: the cyclist
el 9 de Abr. de 2023
Here is one way:
M = [1 100;
2 200;
3 200;
4 200;
5 500];
[~,j] = unique(M(:,2));
out = M(j,:)
0 comentarios
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!