I am trying to figure out how to use writetable instead of xlswrite, but the feature is converting my numbers to text. Headers are text.
15 次查看(过去 30 天)
显示 更早的评论
Original Code that works fine
Excel_Sheet = [Excel_head; Excel_out];
xlswrite('C:\D_Local\MATLAB\AAAA\PhaseII_CA_out.xlsx',Excel_sheet);
Where Excel_head is a text array and Excel_out is a numberical matrix of values.
New Code that converts the numbers to text
Excel_sheet = table([Excel_head; Excel_out]);
writetable(Excel_sheet,'C:\D_Local\MATLAB\AAA\PhaseII_CA_out.xlsx');
why does it convert? There must be a way of making the table with numbers?
Best regards,
Farley
0 个评论
回答(2 个)
Voss
2024-7-9,19:55
Excel_Sheet = array2table(Excel_out,'VariableNames',Excel_head);
writetable(Excel_sheet,'C:\D_Local\MATLAB\AAA\PhaseII_CA_out.xlsx');
0 个评论
Steven Lord
2024-7-9,19:59
Don't concatenate Excel_head and Excel_out together. Store them as separate table variables.
load patients;
LNS = string(LastName);
T = table(LNS, Age, VariableNames = ["Last Name", "Age"]);
head(T)
Compare with the concatenation code, which turns the numeric Age variable into text:
T2 = table([LNS, Age], VariableNames = ["Last Name and Age"]);
head(T2)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!