Effacer les filtres
Effacer les filtres

How to arrange indices of matrix A by descending order ?

1 vue (au cours des 30 derniers jours)
Pradya Panyainkaew
Pradya Panyainkaew le 26 Déc 2017
Commenté : Star Strider le 26 Déc 2017
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.

Réponse acceptée

Star Strider
Star Strider le 26 Déc 2017
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
  2 commentaires
Pradya Panyainkaew
Pradya Panyainkaew le 26 Déc 2017
Thank you very much.
Star Strider
Star Strider le 26 Déc 2017
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by