How to sort a matrix by a predefined order

조회 수: 1 (최근 30일)
Shannon
Shannon 2020년 1월 29일
댓글: Shannon 2020년 1월 29일
I have a matrix, A=[1 2; 3 4; 5 6; 7 8], how to reset the order by B=[1; 4; 3; 2] to get A = [1 2; 7 8; 5 6; 3 4]?
Thanks,

채택된 답변

Sindar
Sindar 2020년 1월 29일
A=[1 2; 7 8; 5 6; 3 4];
B=[1; 4; 3; 2];
A = A(B,:);
  댓글 수: 1
Shannon
Shannon 2020년 1월 29일
Thank you so much! I just figure it out too! Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by