MATLAB: Cell contents assignment to a non-cell array object

cell contents assignment to a non-cell array object

Hi there,
I have written this piece of code to store all the combination into a array of matrices.
for i=1:4,
m = combnk(1:4,i)
tester{i} = repmat(m,1)
end
When I tested it separately, it works fine. But when I combined it with other code in my project, the matlab gave me warning regarding tester{i} = repmat(m,1): Cell contents assignment to a non-cell array object
Anybody can enlighten me on this issue? Thanks a million in advance!

Best Answer

tester = (round(NumberOfElementsInBigMatrix/2));
will create tester as a double array. Then later on you try to assign to it as though it is a cell array in the for loop you provided at the top. If you created it as a double you cannot then assign to it with cell array syntax.
The initial code works standalone because tester was not previously declared as a double so it is created in the loop as a cell array.