How do I add a column to table?
Show older comments
I have created a CSV file. When I use the "readable" function to load the table, I get an 8x10 table. I want to expand the table to an 8x11 table, where the 11th column should have the values from a function I have created. How do I do this?
Accepted Answer
More Answers (3)
Sean de Wolski
on 20 Nov 2015
T.EleventhColumn = rand(8,1);
Where 'EleventhColumn' is the name you want for the variable.
2 Comments
Theodore Wilkening
on 13 Mar 2020
this works best.
Yifei
on 26 Nov 2022
The most convenient approach.
thang ngo
on 24 Jul 2020
14 votes
This helps to pass a name as parameter:
name = 'new_column'
T.(name) = rand(8,1);
Ehab Abdelkarim
on 3 Aug 2018
2 votes
you may want to check the following link https://de.mathworks.com/help/matlab/matlab_prog/add-and-delete-table-variables.html
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!