Reshaping a 2D matrix to a 3D one with specific ordering
Show older comments
Hello,
I have a nxn matrix that i would like to reshape into a (2 x 2 x :) matrix without using any loops and in this way but with reshape:
an example with "n = 4" and:
A = [1 2 3 4;...
5 6 7 8;...
9 10 11 12;...
13 14 15 16]
gives: B(: , : ,1) = [1 2;
5 6]
B(: , : ,2) = [3 4;
7 8]
B(: , : ,3) = [9 10;
13 14]
B(: , : ,4) = [11 12;
15 16]
Thanks !!
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!