Obtain the sorted index vector
조회 수: 27 (최근 30일)
이전 댓글 표시
Suppose a vector with element. in Matlab, I can use the following code to sort the vector in descending order as follow:
y=sort(x,'descend'), for example, x=[0.5; 0.4; 0.6; 0.9], then y=[0.9; 0.6; 0.5; 0.4].
I need to Obtain the sorted index vector. Here it will be z=[4; 3; 1; 2]
I need to find z for any arbitrary sorted vector.
댓글 수: 0
채택된 답변
Bruno Luong
2022년 3월 4일
편집: Bruno Luong
2022년 3월 4일
Use the second output of sort
x=[0.5; 0.4; 0.6; 0.9]
[y,z] = sort(x,'descend')
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!