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!