How to output a row vector to excel?
Ältere Kommentare anzeigen
I have a nested "for" loop calculation and I want to output the results to excel as a row vector each time it runs the loop. So far all the xlswrite command does is overwrite the row A values with the final value being the only one saved.
Kp = 0.03;
Ks = 0.1;
Kt = 0.1;
Kd = 0.1;
for M = [1:1:5]
for R = [.01:0.01:0.1]
%Secondary Flow
W2 = 1.25;
%pirmary Flow rate calculation
W1 = [W2*M]
%Head Ratio N
Nnum = (2*R + (2*(R^2)*(M^2))/(1-R) -(1 + Kt + Kd)*(R^2)*((1+M)^2)- ...
(1+Ks)*((R^2)*(M^2))/((1-R)^2));
Nden = (1+Kp - 2*R - (2*R^2*M^2)/(1-R) + (1 + Kt + Kd)*R^2*(1+M)^2);
N = Nnum/Nden
results = [M R W1 W2 N];
xlswrite ('sizing.xlsx',results)
end
end
Antworten (1)
Walter Roberson
am 11 Dez. 2012
0 Stimmen
Doing what you ask would be quite inefficient. It is expensive to start up the connection to Excel every time.
It would be much more efficient to save the results into an array and then write the array once at the end.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!