save work space variables into excel sheet headlines and columns
2 views (last 30 days)
Show older comments
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 Comment
Answers (1)
Voss
on 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);
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!