x = rand(3,4); y = reshape(x, 3, 1, 4); size(y)
This is such efficient, that it is hard to dare to do this in a loop. Therefore I assume, that the problem is a homework question and to avoid cheating, I ask you to post, what you have done so far to solve it with a loop. Then ask a specific question to the occurring problems.
Play games and win prizes!Learn more