Let say I want to generate 3 matrices of size 3x4
each with random entries rand(3, 4)
. How to put them in a cell
1x3
?
With a loop, it is easy:
A = cell(1, 3);
for i=1:3
A{i}=rand(3, 4);
end
You can store it in a 3 dimensional array:
A = rand(3,4,3);
Access the i-th layer with:
A(:,:,i)