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!