MATLAB: Copy table’s certain data into another table with corresponding variable names

MATLABtabletable propertiesvariable names

Let's say I have a table with 10 rows and 10 columns. I'd like to copy 5 cols and 10 rows of the table into another one with their variable names. Is there a way to do that?
Thank you.

Best Answer

Lets say you want move column Age from table1 to table2
table2.Age=table1.Age
Or if you want to move column 5 to 8 of table1 to table2 do this:
for c=5:8
table2.(T.Properties.VariableNames{c})=table1.(T.Properties.VariableNames{c});
end