how to reverse "sort"
94 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Niki
am 10 Sep. 2011
Kommentiert: Saurabh saini
am 18 Okt. 2021
For example we have a row like
m=[1 6 2 8 9] [Y,I] = sort(m)
then it gives you
Y =
1 2 6 8 9
I =
1 3 2 4 5
But I would like to sort them from big number to small
0 Kommentare
Akzeptierte Antwort
Joan Puig
am 10 Sep. 2011
Hi,
There is an extra optional argument that will do that:
>> m=[1 6 2 8 9]; [Y,I] = sort(m,'descend')
Y =
9 8 6 2 1
I =
5 4 2 3 1
>>
1 Kommentar
Weitere Antworten (1)
Wayne King
am 10 Sep. 2011
Hi, have you read the documentation for sort()?
m = [1 6 2 8 9];
[Y,I] = sort(m,'descend');
Wayne
0 Kommentare
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!