Spec. Cell exportation from a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael
am 14 Okt. 2013
Kommentiert: Michael
am 15 Okt. 2013
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 Kommentare
Jan
am 15 Okt. 2013
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.
Akzeptierte Antwort
Azzi Abdelmalek
am 14 Okt. 2013
Bearbeitet: Azzi Abdelmalek
am 14 Okt. 2013
Move xlswrite from the loop and put it after:
xlswrite('testsheet.xlsx', cat(1,Kapitalwert{:}),'Kapitalwerte');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!