MATLAB: How to include header text in a Table when writing to Excel

arraydataexceltable

Hi All
I have to write a table after converting it to array , to Excel . as you can see in the following example taken from this page, if you print the TT you can see the header. but when I converted it to array and tried to write it to Excel ,there was no header
[c,hist,edges,rmm,idx] = rainflow(Z,t);
TT = array2table(c,'VariableNames',{'Count','Range','Mean','Start','End'})
TT=7×5 table
Count Range Mean Start End
_____ _____ ____ _____ ___
0.5 3 -0.5 0 1
0.5 4 -1 1 3
1 4 1 5 6
0.5 8 1 3 4
1 6 1 10 13
0.5 9 0.5 4 8
0.5 10 1 8 15

Best Answer

In table to array conversion only one type of the data will be displayed, head(string) would skipped.
If you want to write data to excel without converting table to array you can include header
writetable(TT,'output_file.xlsx'); % assumed filename "output_file"