Rearranging matrix in ascending order for value in a column
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
KSSV
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Linear Algebra in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!