MATLAB: Displaying Tabular Data with heading in matlab

fprintf

Dear All, I intend to display result of my calculation in a way that each column will have a heading in the command window. I want x values neatly displayed under x-val; y values under y-val etc; thanks if you can help. Here is my code:
x =1:20;
y= x.^2;
z = x*20;
table =[x; y; z];
disp('Table shows table values')
disp('x-val, y-val, z-val')
fprintf('%8.2f %10.1f %12.2f\n', table)

Best Answer

Try this:
fprintf(' x-val, y-val, z-val\n')
fprintf('--------------------------------\n')
fprintf('%8.2f %10.1f %12.2f\n', table)