Write Data to Excel

7 ビュー (過去 30 日間)
nick12391
nick12391 2019 年 7 月 16 日
回答済み: Walter Roberson 2019 年 7 月 16 日
I'm trying to output variables from my code to an Excel spreadsheet.
var = ['L_Chamber'; 'D_Chamber'; 'D_Throat '; 'L_Nozzle '; 'D_Nozzle '; 'Theta_N '];
val = [L_Chamber; D_Chamber; D_Throat; L_Nozzle; D_Exit; theta_n];
T = table(var,val);
filename = 'TCA_Dims.xlsx';
writetable(T',filename,'Sheet',1,'Range','A1')
This code works well, but I would like for the variable names, 'var', to be written to the top row, and their values, 'val', to be written to the second row. As it is, var and val are written to the first and second columns, respectively.

採用された回答

nick12391
nick12391 2019 年 7 月 16 日
Nevermind, I figured it out:
Table = table(L_Chamber, D_Chamber, D_Throat, L_Nozzle, D_Exit, theta_n);
filename = 'TCA_Dims.xlsx';
writetable(Table,filename,'Sheet',1,'Range','A1')

その他の回答 (2 件)

KSSV
KSSV 2019 年 7 月 16 日
x = rand(3,1) ;
y = rand(3,1) ;
z = rand(3,1) ;
T = table(x,y,z) ;
writetable(T,'test.xlsx')

Walter Roberson
Walter Roberson 2019 年 7 月 16 日
T = table(cellstr(var).', val.');
writetable(T, filename, 'Sheet', 1, 'Range', 'A1', 'writevariablenames', false)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by