How to sort a matrix by a predefined order

2 vues (au cours des 30 derniers jours)
Shannon
Shannon le 29 Jan 2020
Commenté : Shannon le 29 Jan 2020
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,

Réponse acceptée

Sindar
Sindar le 29 Jan 2020
A=[1 2; 7 8; 5 6; 3 4];
B=[1; 4; 3; 2];
A = A(B,:);
  1 commentaire
Shannon
Shannon le 29 Jan 2020
Thank you so much! I just figure it out too! Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by