Rearranging matrix in ascending order for value in a column
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
0.748151592823709 0.913337361501670 0.996134716626885 0.961898080855054
0.450541598502498 0.152378018969223 0.078175528753184 0.004634224134067
0.083821377996933 0.825816977489547 0.442678269775446 0.774910464711502
0.228976968716819 0.538342435260057 0.106652770180584 0.817303220653433
Let's consider I have a matrix like this. I want to rearrange the matrix based on value in the last column in ascending order, so that I would look like below
0.450541598502498 0.152378018969223 0.078175528753184 0.004634224134067
0.083821377996933 0.825816977489547 0.442678269775446 0.774910464711502
0.228976968716819 0.538342435260057 0.106652770180584 0.817303220653433
0.748151592823709 0.913337361501670 0.996134716626885 0.961898080855054
I would do it manual for this case, but my data matrix is 500*8. Is there any option?
0 commentaires
Réponses (1)
KSSV
le 24 Nov 2016
k = [ 0.748151592823709 0.913337361501670 0.996134716626885 0.961898080855054
0.450541598502498 0.152378018969223 0.078175528753184 0.004634224134067
0.083821377996933 0.825816977489547 0.442678269775446 0.774910464711502
0.228976968716819 0.538342435260057 0.106652770180584 0.817303220653433];
[val,idx] = sort(k(:,end)) ;
iwant = k(idx,:)
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra 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!