how to sort matrix according to another matrix in matlab
1 次查看(过去 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-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!