How write multiple data output in excel sheet
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I am currently working on a program that will read a large text file and then export it into an excel file in a different organization. My file i am trying to read contains information in this form...
I'm currently working on a program that calculates and unload output data for different values of the input variable. The program i conducted through two while loops, and now would like to print all data in Excel. The view of all results in notepad editor looks like this:
T_ok T_02 kapa num_iter error T_2
248.15 520.52 1.384537 7 0.000652 561.22
249.15 522.38 1.384314 7 0.000675 563.21
250.15 524.24 1.384092 7 0.000700 565.19
251.15 526.09 1.383869 7 0.000725 567.18
252.15 527.95 1.383646 7 0.000751 569.16
*
*
*
(Number of rows containing floats: 66)
When I try to get something like that in Excel i get an error-it prints out only the last numeric data row.
How can i get my output directly in excel or can i transfer this notepad results into excel. My code looks like this:
clear all
clc
Mzr = 28.96; % kg/kmol Rzr = 0.2871; % KJ/(kgK) pr = 16; % kompresijski omjer: p2/p1 T_ok = 248.15; eta_komp = 0.87;
fileID = fopen('Rezultati.txt','w'); fprintf(fileID,'\r T_ok T_02 kapa num_iter error T_2'); fprintf(fileID,'\r\n===================================================================='); while T_ok <= 313.15 k_0 = 1.4; eps = 1; iter = 1;
while abs(eps) > .001
T_02 = T_ok * pr^(k_0 - 1)/k_0;
load kapa_zraka.txt;
k_new = interp1(kapa_zraka(:, 1), kapa_zraka(:, 4), T_02);
T_new = T_ok * pr^(k_new - 1)/k_new;
eps = T_02 - T_new;
T_02 = T_new;
k_0 = k_new;
iter = iter + 1;
T_2 = T_ok + (T_new - T_ok)/eta_komp;
end
fprintf(fileID,'\r\n%.2f %10.2f %13f %14.0f %17f %12.2f %14.2f %14f\r\n\r\n',T_ok,T_02,k_0,iter,abs(eps),T_2);
T_ok = T_ok+1;
end
fclose(fileID)
0 Commenti
Risposta accettata
Image Analyst
il 2 Giu 2013
Just make up your cell array to cover the whole sheet. For the blank cells in between the two separated ranges, just have the cell be {[]}. See the FAQ if you want to know what a cell array is. Then you can write the whole sheet in just one call to xlswrite().
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!