Making a text heading to a table with numbers

6 visualizaciones (últimos 30 días)
Taikhum Vahanvaty
Taikhum Vahanvaty el 19 de Abr. de 2021
Editada: David Fletcher el 19 de Abr. de 2021
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!

Respuestas (1)

David Fletcher
David Fletcher el 19 de Abr. de 2021
Editada: David Fletcher el 19 de Abr. de 2021
%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.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by