필터 지우기
필터 지우기

Cell contents assignment to a non-cell array object.

조회 수: 2 (최근 30일)
Michael
Michael 2013년 10월 12일
댓글: Walter Roberson 2013년 10월 14일
Hey guys,
i do have this little code to program. what i dont understand is, when i run it without the inner for-loop, there is now error. when i run with the loop, there is this error that i dont understand. Anybody able to help me finding the bug ?
C = cell(28, 1);
for i=1:1:28;
C{i} = UM(i,:);
IPV = C{i,1}(1);
IB = C{i,1}(2);
IWP = C{i,1}(3);
IK = C{i,1}(4);
IWS = C{i,1}(5);
for p = 1:1:2;
Bundesland=p;
OptimierungPV_B_WP_mitWaermespeicher_Bandu_14;
Kapitalwert(1,1) = num2cell(ZFW);
if Bundesland == 1;
xlswrite('testsheet.xlsx', ...
Kapitalwert, ...
'Kapitalwerte','A1:A28');
elseif Bundesland == 2;
xlswrite('testsheet.xlsx', ...
Kapitalwert, ...
'Kapitalwerte','B1:B28');
end;
end;
end;
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 12일
Where is the line causing this error?
Walter Roberson
Walter Roberson 2013년 10월 12일
The line with problems is likely
Kapitalwert(1,1) = num2cell(ZFW);
which would be a problem if Kapitalwert exists but was not a cell array at the time of the assignment.

댓글을 달려면 로그인하십시오.

채택된 답변

Michael
Michael 2013년 10월 14일
thanks for your help.
i solved the problem by renaming the cell array. I used the variable C already in the program i call in line 11 ("Optimierung ..."). that's why it worked for the first loop and stopped afterwards.
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 10월 14일
Ah. Usually we assume that calls to user routines are functions unless they are clearly scripts.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Michael
Michael 2013년 10월 14일
thanks for your quick answers.
@no, i have not initialized it yet. here, it is the first time i put it. why is it likely to be to be the problem and how may i solve it ?
@azzi: the line causing error is the third line.
thanks for your support.
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 10월 14일
The code you give is not going to have a problem at C{i} = UM(i,:) even if UM is a cell array. Not unless there is some additional code you have not shown, between the C = cell(28,1); and the code you show.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by