No can do unless convert the table variables to cell arrays; a double array cannot have anything other than numeric values. A MATLAB table data structure is NOT a spreadsheet although it superficially appears somewhat akin to one...
a=randi([2000 6999],12,1); a(2:2:end)=nan; b=a+1;
tT=table(a,b)
tT =
a b
____ ____
5993 5994
NaN NaN
3312 3313
NaN NaN
6881 6882
NaN NaN
6714 6715
NaN NaN
2698 2699
NaN NaN
5345 5346
NaN NaN
illustrates don't need a loop nor concatenation to do the first step...
If it really, really, really were important to not have the NaN values showing, one would have to do something like
a=string(a); b=string(b);
a(ismissing(a))=""; b(ismissing(b))="";
tT=table(a,b)
tT =
a b
______ ______
"5993" "5994"
"" ""
"3312" "3313"
"" ""
"6881" "6882"
"" ""
"6714" "6715"
"" ""
"2698" "2699"
"" ""
"5345" "5346"
"" ""
is rough equivalent of the cell route; a string array can be the null string rather than missing. MATLAB will then display the double-quotes around the values as the visual type indication in the command window.
You would have to fprintf the values with formatting string to get them to look differently.
The cellstr route would be the same idea; it displays "the curlies" around cell values...
tT=addvars(tT,cellstr(tT.a),'After','b','NewVariableName','c')
tT =
a b c
______ ______ __________
"5993" "5994" {'5993' }
"" "" {0×0 char}
"3312" "3313" {'3312' }
"" "" {0×0 char}
"6881" "6882" {'6881' }
"" "" {0×0 char}
"6714" "6715" {'6714' }
"" "" {0×0 char}
"2698" "2699" {'2698' }
"" "" {0×0 char}
"5345" "5346" {'5345' }
"" "" {0×0 char}