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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by