sorting data in matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kieran
le 18 Oct 2013
Modifié(e) : Andrei Bobrov
le 18 Oct 2013
say i have a matrix
a = [2 3; 1 3; 3 2; 2 2; 1 2; 3 1; 2 1; 1 1]
i would like to rearrange a such that the first column is sorted in ascending order corresponding to the number in the second column ie. this matrix should become
asorted = [1 3; 2 3; 1 2; 2 2; 3 2; 1 1; 2 1; 3 1]
how can this be done automatically
0 commentaires
Réponse acceptée
Andrei Bobrov
le 18 Oct 2013
Modifié(e) : Andrei Bobrov
le 18 Oct 2013
asorted = sortrows(a,[-2 1])
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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!