Making a text heading to a table with numbers
4 次查看(过去 30 天)
显示 更早的评论
I have a matrix A = [ 0,0,0,0; 3,4,5,6; 7,8,9,1].
I want the first row to have text headings, Like A = [ cats, dogs, ants, fish; 3, 4, 5, 6; 7, 8, 9, 1].
How can I do this? I believe I willhave to create a cell array? So if I create a new matrix with the text headings first, how can I assign the numbers to this cell array? Eventually I want to be able to write this table in an excel sheet (.csv format) and the numbers should appear as numbers only.
Thank you for your help!
0 个评论
回答(1 个)
David Fletcher
2021-4-19
编辑:David Fletcher
2021-4-19
%Creat table with named fields
tbl=table(3,4,5,6, 'VariableNames',{'Cats', 'Dogs', 'Ants', 'Fish'})
%Add row(s)
tbl{end+1,:}=[7 ,8 , 9, 1]
As for Excel, I personally rarely touch it, but I believe you can use writetable to save a table in Excel spreadsheet format.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!