combined sorting
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
For ex;I have an array A=[1:4] and B=[12:19:2:20].If I sort B in descending order B=[20 19 12 2].I want the corresponding positions in A to be swapped as well...ie A=[4 2 1 3].How do I achieve that?
0 Kommentare
Akzeptierte Antwort
Matt Tearle
am 3 Apr. 2011
[sortB,idx] = sort(B,'descend');
sortA = A(idx);
Or put the vectors into a matrix and use sortrows.
2 Kommentare
Weitere Antworten (0)
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!