How to add columns with fixed values to their exact position in the table
1 view (last 30 days)
Show older comments
Akashdeep Kaur
on 18 Jul 2022
Commented: Abderrahim. B
on 18 Jul 2022
Hello, I have a table with 16 columns. Some columns have variable value and some have fixed value.
I fixed their values like:
simtable.datacenters(:)="Cloud_1";
Now, This column is at no. 4 in my table. but, when printing output it gets printed at last.
I also want to generate its excel sheet but the columns with fixed values are not added to excel sheet.
Thank you.
0 Comments
Accepted Answer
Abderrahim. B
on 18 Jul 2022
Edited: Abderrahim. B
on 18 Jul 2022
Hi,
Use addvars instead of dot notation to add columns to your table.
Demo:
load patients
T = table(Age,Gender,Smoker) ;
% add a new column to T table before Age
T = addvars(T,LastName,'Before','Age')
Hope this helps
10 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!