Rearranging values in a matrix
Ältere Kommentare anzeigen
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!
Antworten (1)
Von Duesenberg
am 11 Mär. 2018
Suppose your initial matrix is called oldMat:
reshape(oldMat', [5, 4])'
3 Kommentare
Stephen23
am 11 Mär. 2018
reshape(oldMat.', [5,4]).'
Von Duesenberg
am 11 Mär. 2018
Thanks for the tip.
Gregory Olive
am 11 Mär. 2018
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!