xlswrite formatting error. Naming multiple sheets
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Stephen Dzuryk
le 5 Sep 2018
Rouvert : Walter Roberson
le 22 Déc 2018
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 commentaires
Réponse acceptée
Bob Thompson
le 5 Sep 2018
Modifié(e) : Bob Thompson
le 5 Sep 2018
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.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!