How to arrange indices of matrix A by descending order ?

조회 수: 3 (최근 30일)
Pradya Panyainkaew
Pradya Panyainkaew 2017년 12월 26일
댓글: Star Strider 2017년 12월 26일
if I have
A=[25,41,38] when I sort this matrix by descending order , I will get A=[41,38,21]
I want to arrange indices of matrix A by descending order and shows a result (B) like this
B=[2,3,1]
How to create program to get this result ?
Thanks in advance.

채택된 답변

Star Strider
Star Strider 2017년 12월 26일
To get ‘B’, ask for the second output from sort:
A=[25,41,38];
[A_sorted,B] = sort(A, 'descend')
A_sorted =
41 38 25
B =
2 3 1

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by