Rearranging matrix in ascending order for value in a column

조회 수: 1 (최근 30일)
young jin Kwak
young jin Kwak 2016년 11월 24일
답변: KSSV 2016년 11월 24일
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?

답변 (1개)

KSSV
KSSV 2016년 11월 24일
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,:)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by