Obtain the sorted index vector
32 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
YAHYA AL-MOLIKI
am 4 Mär. 2022
Kommentiert: YAHYA AL-MOLIKI
am 4 Mär. 2022
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 Kommentare
Akzeptierte Antwort
Bruno Luong
am 4 Mär. 2022
Bearbeitet: Bruno Luong
am 4 Mär. 2022
Use the second output of sort
x=[0.5; 0.4; 0.6; 0.9]
[y,z] = sort(x,'descend')
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!