필터 지우기
필터 지우기

Spec. Cell exportation from a loop

조회 수: 1 (최근 30일)
Michael
Michael 2013년 10월 14일
댓글: Michael 2013년 10월 15일
Hi guys,
This is the code:
M = cell(28,1);
for i=1:28;
M{i} = UM(i,:);
IPV = M{i,1}(1);
IB = M{i,1}(2);
IWP = M{i,1}(3);
IK = M{i,1}(4);
IWS = M{i,1}(5);
OptimierungPV_B_WP_mitWaermespeicher_Bandu_14;
Kapitalwert(i,1)= num2cell(ZFW);
xlswrite('testsheet.xlsx', ...
Kapitalwert{i}, ...
'Kapitalwerte','A1:A28');
end
As you can see, i want to export a specific value from the calculation in line 11. The program does export, but ONLY the value from the first run of the loop, it conitnues writing this value for all the 28 runs of the loop. There must be different values for this of ZFW which is returned as Kapitalwert. Can sb help me to understand and find the error ?
Thanks a lot.
  댓글 수: 3
Michael
Michael 2013년 10월 14일
편집: Michael 2013년 10월 14일
Sorry, i changed my question due to your commentaries. line 9 is a .m file. ('OptimierungPV_B_WP_mitWaermespeicher_Bandu_14;'). If i make run this program, it returns a ZFW value after running it.
The excel file can be overwritten in each iteration, but i want to export each ZFW being calculated in the extern program in one column. You can be sure that ZFW is generated in this program, but in each run ,it differs from the previous. So i want to export it after each of the 28 runs. If i wasnt able to cvlarify, please tell me, im trying to give another try.
Jan
Jan 2013년 10월 15일
No, obviously OptimierungPV_B_WP_mitWaermespeicher_Bandu_14 does not return anything. Therefore I guess it is a script. Scripts have the disadvantage, that they can access all variables of the caller, intentionally and unintentionally. In consequence, you cannot debug the program sufficiently without knowing the source code of the script.

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 14일
편집: Azzi Abdelmalek 2013년 10월 14일
Move xlswrite from the loop and put it after:
xlswrite('testsheet.xlsx', cat(1,Kapitalwert{:}),'Kapitalwerte');
  댓글 수: 1
Michael
Michael 2013년 10월 15일
the programm put only one value in cell A1:A1
but i need 28 ?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by