How to arrange indices of matrix A by descending order ?

2 次查看(过去 30 天)
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