MATLAB: How to preallocate 3 D matrix

random number generator

Hello,
Suppose output(:,:) is matrix with 5 rows and 10 columns.
u is from 1 to n. So, i will have n different output(:,:) matrix's which i am saving in outp(:,:,u).
for u= 1:n
outp(:,:,u) = output(:,:);
end
then how can i pre allocate outp(:,:,u) with zeros so that i can increase speed.
will it be outp(:,:,u)= zeros(5*n,10)?
Thank You

Best Answer

outp(:,:,u)= zeros(5, 10, n)