write different data types to excel sheet
显示 更早的评论
Hello,
I have a small matrix of data that contains a column of real numbers, a column of integers and a column of cell data. It appears to be stored as cell data, but I would like to keep the format of real, integer and string (different lengths) when I write to an excel spreadsheet. Using writematrix works to write the cell data, but I can't change the data type after that.
line0 is my cell table, and I use:
- writematrix(line0,filename,"Sheet",3,Range="A2:C13")
I could use help with the ability to format the data when writing to the excel file
回答(1 个)
"It appears to be stored as cell data"
It is clearly stored as a string array:
S = load('Variable.mat')
S.line0
T = array2table(S.line0, 'VariableNames',S.CCHdr);
T = convertvars(T,[1,2],@double)
writetable(T,'myexcel.xlsx')
类别
在 帮助中心 和 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!