How do I make a MATLAB created table properly appear in EXCEL?
Ältere Kommentare anzeigen
I'm attempting to write a MATLAB created table to EXCEL using the following code;
%
% Write_Parts_Table.m
%
% Clear out all workspace variables and the command window
clear all;
clc;
% Assign data
Company = {'Company_A' 'Company_B'};
Run_Numbers = {'10000' '2500'};
Make = {{'Ford' 'Audi' 'Chevy'} {'Chevy' 'Volvo'}};
% Create table from workspace variables
Z = table(Company', Run_Numbers', Make', 'VariableNames',{'Company_Name' 'Run_Numbers' 'Make'});
% Disable the warnings for adding specified worksheets. These occur because
% EXCEL has a default value of 3 worksheets / file
warning('off', 'MATLAB:xlswrite:AddSheet');
% Write table to EXCEL
writetable(Z, '(A)Parts_Info.xls', 'Sheet', 1, 'Range', 'A3');
% For inspection, have Windows open the EXCEL workbook just created
winopen('(A)Parts_Info.xls');
When I view the variable Z, I get the following;
'Company_A' '10000' 1x3 cell
'Company_B' '2500' 1x2 cell
When EXCEL is opened, I see the following;
Company_Name Run_Numbers Make
Company_A 10000
Company_B 2500
But I expect to see this;
Company_Name Run_Numbers Make
Company_A 10000 Ford Audi Chevy
Company_B 2500 Chevy Volvo
It appears I have some kind of problem pertaining to the size of the data in the 'make' column.
Is this a case where I need to add more column headers? Or am I using the writetable incorrectly?
Thank you.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!