xlswrite formatting error. Naming multiple sheets
2 ビュー (過去 30 日間)
古いコメントを表示
I am very new to MATLAB.
Currently, I have to use the following code to export my data to Excel but would like to reduce the number of lines needed if possible and change the "sheet" name of all of them at once.
Data = {'MATLAB DATA'};
Data1 = {'Reactor Length (m)', 'Molar flow of A (mol/s)', 'Molar flow of B (mol/s)', 'Molar flow of C (mol/s)', 'Molar flow of D (mol/s)','Reaction Rate (mol/(m^3*s))'};
Data2 = [Z Fa Fb Fc Fd rA2];
Data3 = {'Reactor Radius (m)', Ro}
Data4 = {'Reactor Pressure (Bar)', P_Bar}
Data5 = {'Reactor Temperature (K)', T}
xlswrite('PFR_Data.xlsx', Data, '3 H2 1 CO2', 'A1:A6')
xlswrite('PFR_Data.xlsx', Data1, '3 H2 1 CO2', 'A3')
xlswrite('PFR_Data.xlsx', Data2, '3 H2 1 CO2', 'A4')
xlswrite('PFR_Data.xlsx', Data3, '3 H2 1 CO2', 'A2')
xlswrite('PFR_Data.xlsx', Data4, '3 H2 1 CO2', 'C2')
xlswrite('PFR_Data.xlsx', Data5, sheet, 'E2')
When I try
sheet = {'5 H2 1 CO2'}
xlswrite('PFR_Data.xlsx', Data, sheet, 'A1:A6')
I get the following error
Error using xlswrite (line 172)
Sheet argument must be a character vector or a whole number greater than 0.
Any help will be appreciated.
0 件のコメント
採用された回答
Bob Thompson
2018 年 9 月 5 日
編集済み: Bob Thompson
2018 年 9 月 5 日
Using sheet = {} defines the variable 'sheet' as a cell containing a character string with the name. If you do sheet{1} or something similar that should be the quickest solution.
Alternatively, you should be able to define sheet without the cell brackets.
sheet = '5 H2 1 CO2';
which should define sheet just as the sheet string name, rather than as a cell containing the name.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!