MATLAB: How to change this to give me [4×5 double] arrays in the cell array

cell arraysMATLAB

Here is my code:
%Input the length and width of the room
L = 4;
W = 5;
A = zeros(L,W);
B = zeros(L,W);
C = cell(L,W);
for n = 1:L
for m = 1:W
C{n,m} = size(A);
end
end
And the output: C =
[1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double]
[1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double]
[1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double]
[1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double]
I figured it would give me 5×4 arrays but it is not.

Best Answer

I don't see how you got that. I don't get that at all. Inside each cell is a 1 by 2 array that is what is returned by the size() function. size(A) returns [4, 5] which is what is inside each cell of the cell array. And you have a 4-by-5 array of cells that are all identical, with a double array of [4, 5] inside each.
Please read the FAQ http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F so that you will attain a better intuitive understanding of how cells work.