Find unique number sets
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Given a 2D matrix, I'd like to find the number of rows with unique sets of numbers. For example:
A = [1 4;
2 3;
3 2;
1 4];
The "unique sets" matrix return should be:
B = [1 4;
2 3];
and the indices of these should be
iA = [1 2];
Using unique(A,'rows') sees [2 3] and [3 2] as unique, but I want to consider them as non-unique.
0 commentaires
Réponse acceptée
Plus de réponses (1)
Les Beckham
le 4 Août 2022
Modifié(e) : Les Beckham
le 4 Août 2022
A = [1 4;
2 3;
3 2;
1 4];
B = unique(sort(A, 2), 'rows')
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!