save work space variables into excel sheet headlines and columns

4 vues (au cours des 30 derniers jours)
amjad almaarafawi
amjad almaarafawi le 14 Déc 2019
Réponse apportée : Voss le 2 Jan 2024
Hi, I have a lone code with about 7 variables Im trying to save into excel sheet with the variables names as headline and the data into the column of that headline. all the varables are matrix 20x1 and the names are listed below.
r_coords
extracted_data
r_exper
V_exper
V_interpolation
Absuolut_Error
Relative_Error
filename = (sprintf('monitor_line_%d_ degree %.1fCA_%s', Monitor_line, CrankAngle, upper(variable)));
Results_Names={'r_coords','extracted_data','r_exper','V_exper','V_interpolation','Absuolut_Error','Relative_Error'};
Results_Values=[r_coords,extracted_data,r_exper,V_exper,V_interpolation,Absuolut_Error,Relative_Error];
sheet=1;
xlswrite('filename.xlsx',Results_Values,sheet);
  1 commentaire
Sahithi Kanumarlapudi
Sahithi Kanumarlapudi le 17 Déc 2019
Could you give some information on the issue being faced?

Connectez-vous pour commenter.

Réponses (1)

Voss
Voss le 2 Jan 2024
One way to write the file:
C = [Results_Names; num2cell(Results_Values)];
writecell(C,filename)
Another way to write the file:
T = array2table(Results_Values,'VariableNames',Results_Names);
writetable(T,filename)
Another (not recommended) way to write the file:
sheet=1;
C = [Results_Names; num2cell(Results_Values)]
xlswrite(filename,C,sheet);

Community Treasure Hunt

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

Start Hunting!

Translated by