MATLAB: Merge arrays into table and keep the variable names

arraytablevariable names

How can I merge arrays into a table and keep the variable names from the arrays=. I have tried to merge arrays into table like this:
table(array1,array2,array3);
In the new table the variable names is shown as var1,var2 and var3. I want the variable names to be shown as array1, array2 and array3. How can I do this?

Best Answer

table function has VariableNames option, which can be used as follows:
array1=[1;2];
array2=[3;4];
array3=[5;6];
table(array1,array2,array3,'VariableNames',{'array1','array2','array3'})