Using the unique function to eliminate rows containing the same integers in a different order.
Mostrar comentarios más antiguos
Hi,
I have an N x 2 array containing integers as shown below.
D = [1 4; 1 5; 2 3; 2 4; 2 5; 3 2; 4 1; 4 2; 4 5; 5 1; 5 2; 5 4]
I wish to remove rows that repeat numbers such as D(1,:) = [1 4] and D(:,7) = [4 1]. In this case, I would want to remove D(:,7) from the array as row 1 already contains numbers 1 and 4.
I typically use the unique function to both sort and filter my data in cases like this, however due to the different indices I have not yet managed to get this method to work.
[members]=unique(D,'rows');
Note: My desired output matrix is as follows:
D = [1 4; 1 5; 2 3; 2 4; 2 5; 3 2]
Any guidance would be very much appreciated!
Sam
1 comentario
James Tursa
el 5 de Oct. de 2017
Editada: James Tursa
el 5 de Oct. de 2017
Assuming that last [3 2] row is a typo should be [4 5] in your example.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!