how to sort matrix according to another matrix in matlab
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a two matrix
A=[ 1 2 3;
2 1 4;
1 3 2; ]
and
B=[1 2 3]
i want the output matrix like,
C =[1 2 3;
1 2 4;
1 2 3]
how to get this output. The matrix A is sorted according to the matrix B.
Thanks.
4 Kommentare
Azzi Abdelmalek
am 2 Nov. 2012
Bearbeitet: Azzi Abdelmalek
am 2 Nov. 2012
what if B=[1 3 2] what should be C
Akzeptierte Antwort
Azzi Abdelmalek
am 1 Nov. 2012
Bearbeitet: Azzi Abdelmalek
am 1 Nov. 2012
sort(A,2)
gives the result but had nothing to do with B
maybe you want this
C=sort(A,2)
C=C(:,B)
0 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!