How to find unique rows with unordered elements?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Oliver
le 13 Jan 2014
Modifié(e) : Azzi Abdelmalek
le 13 Jan 2014
Say I have the following matrix:
>> A = [1 2 3; 2 4 6; 3 1 2; 1 1 1]
A =
1 2 3
2 4 6
3 1 2
1 1 1
How can I identify the unique rows where I don't care what order the row elements are in? For example, in this case row 1 is equivalent to row 3 because both contain the elements 1, 2, and 3, the only difference is their order. So the unique rows would be A([1,2,4],:).
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 13 Jan 2014
Modifié(e) : Azzi Abdelmalek
le 13 Jan 2014
A = [1 2 3; 2 4 6; 3 1 2; 1 1 1]
[idx,idx]=unique(sort(A')','rows','stable');
B=A(idx,:)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!