How to sort a matrix by a predefined order

1 次查看(过去 30 天)
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,:);

更多回答(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