Using the unique function to eliminate rows containing the same integers in a different order.
Mostra commenti meno recenti
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 Commento
James Tursa
il 5 Ott 2017
Modificato: James Tursa
il 5 Ott 2017
Assuming that last [3 2] row is a typo should be [4 5] in your example.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!