how to sort matrix according to another matrix in matlab
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Azzi Abdelmalek
2012 年 11 月 2 日
編集済み: Azzi Abdelmalek
2012 年 11 月 2 日
what if B=[1 3 2] what should be C
採用された回答
Azzi Abdelmalek
2012 年 11 月 1 日
編集済み: Azzi Abdelmalek
2012 年 11 月 1 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!