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!

2 件のコメント

Adam
Adam 2015 年 3 月 7 日
Is tester pre-declared or is it just created and resized in the loop?
jessica xiang
jessica xiang 2015 年 3 月 7 日
I have tested the other part of the code. No error. Just in case, I attached the full code here (but no excel sheet):
% Load demand excelfile
[num_demand,txt_demand,raw_demand] = xlsread('Testing_Demand.xlsx');
A = num_demand;
APrime = sum(A);
NumberOfElementsInBigMatrix = APrime(1,3);
tester = (round(NumberOfElementsInBigMatrix/2));
BigMatrix = cell(tester^2,(NumberOfElementsInBigMatrix-tester)^2);
% load supply excelfile
[num_incoming,txt_incoming,raw_incoming] = xlsread('Testing_Incoming.xlsx');
B = num_incoming;
[num_pivot,txt_pivot,raw_pivot] = xlsread('CoreToPartsPivot.xlsx');
C = num_pivot;
%convert demand core to part level
D = zeros(940,1); %matrix to store converted components
for j=1:940,
for i=1:27,
%dont have 10R6700/reserve the last one as 10R6700; But components are not calculated
if isnan(C(j,i))
else
D(j,1)= D(j,1) + B(i,3)*C(j,i);
end
end
end
for i=1:4,
m = combnk(1:4,i)
tester{i} = repmat(m,1)
end
for i=1:4,
tester{i}
end

サインインしてコメントする。

 採用された回答

Adam
Adam 2015 年 3 月 7 日
編集済み: Adam 2015 年 3 月 7 日

0 投票

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.

1 件のコメント

jessica xiang
jessica xiang 2015 年 3 月 7 日
Omg! Yes! you are right! Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by