How do you transpose a part of a column into more rows in Matlab?
2 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
the cyclist
2018-11-30
编辑:the cyclist
2018-11-30
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.
2 个评论
the cyclist
2018-12-5
No problem. The best form of thanks is to upvote and/or accept answers that were helpful. This rewards the person who helped you, and can guide future people looking for similar solutions.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!