That can be easily accomplished using the VariableNames
parameter of the array2table function (the same is valid for the cell2table function too), as follows:
A = [
86 84
45 65
2 42
44 29
];
T = array2table(A,'VariableNames',{'X' 'Y'})
The output table is:
T =
X Y
__ __
86 84
45 65
2 42
44 29
For an already existing table, you can use the same property on the instance itself in order to change its column names:
A = [
86 84
45 65
2 42
44 29
];
T = array2table(A,'VariableNames',{'X' 'Y'})
T.Properties.VariableNames = {'U' 'V'};
T
Take a look at the outputs:
T =
X Y
__ __
86 84
45 65
2 42
44 29
T =
U V
__ __
86 84
45 65
2 42
44 29