Integrating Indices
Ältere Kommentare anzeigen
Hello,
I have taken the matrix below and sorted it ascending by row:
(Original) A=[1 4 5; 3 -1 8; 12 7 9; 4 10 -5];
(Sorted By Row) B=[1 4 5; -1 3 8; 7 9 12; -5 4 10];
I would like to have the indices of the original matrix appear in the locations of the sorted matrix. For this case it would look like this.
(Original) A=[1 2 3; 1 2 3; 1 2 3; 1 2 3];
(Sorted By Row) B=[1 2 3; 2 1 3; 2 3 1; 3 1 2];
I have tried several different methods but with no luck. Any assistance is appreciated
Thanks
1 Kommentar
zohar
am 21 Feb. 2011
Hi Daniel
Give us some code and use the code formatting.
Akzeptierte Antwort
Weitere Antworten (2)
Daniel
am 21 Feb. 2011
2 Kommentare
Oleg Komarov
am 21 Feb. 2011
A=[ 4 3; 8 4;-1 -5; 2 7];
[sorted_A, sort_indexes] = sort(A,2)
gives exactly the second matrix...
Daniel
am 21 Feb. 2011
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!