Rearranging values in a matrix

5 vues (au cours des 30 derniers jours)
Gregory Olive
Gregory Olive le 11 Mar 2018
Commenté : Gregory Olive le 11 Mar 2018
I have a matrix that has 4 columns and I would like to rearrange it to have 5 columns so that the value in the second row first column becomes the value in the first row fifth column. So if the matrix was:
[1 2 3 4
5 1 2 3
4 5 1 2
3 4 5 1
2 3 4 5]
It would become:
[1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5]
Does anybody know how I could do this? Thanks in advance!

Réponses (1)

Von Duesenberg
Von Duesenberg le 11 Mar 2018
Suppose your initial matrix is called oldMat:
reshape(oldMat', [5, 4])'
  3 commentaires
Von Duesenberg
Von Duesenberg le 11 Mar 2018
Thanks for the tip.
Gregory Olive
Gregory Olive le 11 Mar 2018
Awesome thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Spline Postprocessing 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