MATLAB: Transform a two dimensional into a three dimensional and combine with another three dimensional array

catconcatenaterepmatthree-dimensional

Hi, I have this matrix
A=randn(4,3);
and I want to transform it in a three dimensional matrix by stacking that matrix 5 times (without using repmat). Then, I want to horizontally combine that matrix with the matrix
B=zeros(4,10,5)
Could you help me? Thanks a lot!

Best Answer

A=randn(4,3)
out=[A(:,:,ones(1,5)) zeros(4,10,5)]