Help with exporting tables, as separate tabs, into an Excel Sheet
3 次查看(过去 30 天)
显示 更早的评论
Hi, would anyone please be able to assist with this.
I have written several lines of code that generate specific tables. These are the lines of code with their generated tables all in one script.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1453822/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1453827/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1453832/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1453837/image.png)
At at the end, I have written additional code that exports the tables into an Excel sheet but doesnt seem to be working. How can I use the 'writetable' function correctly to export both of these tables as seperate tabs into 1 excel sheet?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1453842/image.png)
Any help would be freatly appreciated. Thankyou.
7 个评论
Stephen23
2023-8-9
编辑:Stephen23
2023-8-9
% Create a cell array to hold your tables
tables = { Total_Drivehsaft_Torque , Driveshaft_Speed };
names = {'Total Driveshaft Torque','Total Driveshaft Speed'};
% Specify the filename for the Excel file
excelFilename = 'Excel Export from SRDC_MIDAS_Simulations.xlsx';
% Write each table to a separate sheet in the Excel file
for k = 1:numel(tables)
writetable(tables{k}, excelFilename, 'Sheet',names{k})
end
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!