How to reorder matrix from one column to MxN matrix

3 visualizzazioni (ultimi 30 giorni)
I have a matrix 1x15 --> A = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15]
And I want to change the order into matrix 3x5 --> A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15]
Any idea how to do this? i have tried reshape but didn't work well. thank you.

Risposta accettata

Voss
Voss il 4 Mag 2022
A = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
reshape(A,5,[]).' % reshape to 5x3, then transpose to 3x5
ans = 3×5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by