MATLAB: Add table variable and assign constant string

MATLABtable string

I want to add a new variable to a table and assign a string to that variable for every row of the table.
T = table({'A';'B';'C'},[1;2;1],[6;7;5],...
'VariableNames',{'Section' 'Data1' 'Data2'})
newString = "Project A"
T.newVar(:) = {newString}
T =
Section Data1 Data2 newVar
_______ _____ _____ __________
'A' 1 6 [1x0 cell]
'B' 2 7 [1x0 cell]
'C' 1 5 [1x0 cell]
What I'd like is….T=
Section Data1 Data2 newVar
_______ _____ _____ __________
'A' 1 6 'Project A'
'B' 2 7 'Project A'
'C' 1 5 'Project A'

Best Answer

T.newVar = repmat({newString}, size(T,1), 1)