How do I convert a 2d matrix to a 3d matrix?
191 次查看(过去 30 天)
显示 更早的评论
A(:,:,1) = ones(2,4);
A(:,:,2) = 2*ones(2,4);
A(:,:,3) = 3*ones(2,4);
C = [ones(2,4);2*ones(2,4);3*ones(2,4)];
However, how do I convert 2d matrix C back to 3d matrix A?
A(:,:,1) =
1 1 1 1
1 1 1 1
A(:,:,2) =
2 2 2 2
2 2 2 2
A(:,:,3) =
3 3 3 3
3 3 3 3
C =
1 1 1 1
1 1 1 1
2 2 2 2
2 2 2 2
3 3 3 3
3 3 3 3
0 个评论
采纳的回答
Akira Agata
2018-12-26
It's time to use reshape function! Please try the following:
A = reshape(C',[2,3,3]);
更多回答(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!