Sort Index - Bug
Ältere Kommentare anzeigen
[a, sort_index]=sort([100;20;30;40])
The sort_index should return
4
1
2
3
But it does not.
Akzeptierte Antwort
Weitere Antworten (1)
James Tursa
am 19 Sep. 2019
The sort index gives the location in the original array of the sorted values. I.e., the sort results "a" are "original_array(sort_index)"
>> x = [100;20;30;40];
>> [a,sort_index] = sort(x)
a =
20
30
40
100
sort_index =
2
3
4
1
>> x(sort_index)
ans =
20
30
40
100
>> isequal(x(sort_index),a)
ans =
1
1 Kommentar
Rainer Ng
am 19 Sep. 2019
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!