MATLAB: How do you transpose a part of a column into more rows in Matlab

MATLABtranspose a part of a column into more rows

Hi!
I imported an excel file in Matlab:
A1 A2 A3
B1 1 10 19
B2 2 11 20
B3 3 12 21
B4 4 13 22
B5 5 14 23
B6 6 15 24
B7 7 16 25
B8 8 17 26
B9 9 18 27
and I need to transpone the columns in rows as follow:
A1 A2 A3 A4 A5 A6 A7 A8 A9
B1 1 2 3 10 11 12 19 20 21
B2 4 5 6 13 14 15 22 23 24
B3 7 8 9 16 17 18 25 26 27
B4
B5
B6
B7
B8
B9
But note, the complete dataset I have is formed by 20 columns and 105 rows.
How can I do the transposition in the whole dataset?
Thank you!

Best Answer

If X is your original matrix ...
Y1 = reshape(X,3,3,[]);
Y2 = permute(Y1,[2,1,3]);
Y3 = reshape(Y2,3,9);
Y3 is the matrix you want as output.
You will probably need to use something other than 3 and 9 as the reshaping parameters, for your larger matrix.