How to reshape matrix in this way?
3 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I was wondering if anyone could help me in a simple question in matrix reshaping.
I have a 3x4 matriz M, as it follows:
M = [1 2 3 4;
5 6 7 8;
9 10 11 12]
I would like to reshape M to have the following matrix N:
N = [1 2;
3 4;
5 6;
7 8;
9 10;
11 12]
I have tried 'reshape' command, but failed. Can anyone please help?
Thanks in advance!
0 个评论
采纳的回答
the cyclist
2020-5-12
编辑:the cyclist
2020-5-12
N = reshape(M.',2,6).';
You need to transpose first (and later back again), because the reshape command works down the columns.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!