% fprintf example script - table output

% set up vectors for lengths, widths, and heights
lengths = [12 5.375 11 11.875];
widths = [12 8.675 8.5 3.375];
heights = [5.5 1.675 5.5 13.675];

% compute volumes and girths
volumes = lengths.*widths.*heights;
girths = sqrt(lengths.^2 + widths.^2 + heights.^2);

% display table
fprintf('Length (in)\tWidth (in)\tHeight (in)\tVolume (in^3)\tGirth (in)\n');
fprintf('%11.3f\t%10.3f\t%11.3f\t%13.3f\t%10.3f\n',lengths(1),widths(1),heights(1),volumes(1),girths(1));
fprintf('%11.3f\t%10.3f\t%11.3f\t%13.3f\t%10.3f\n',lengths(2),widths(2),heights(2),volumes(2),girths(2));
fprintf('%11.3f\t%10.3f\t%11.3f\t%13.3f\t%10.3f\n',lengths(3),widths(3),heights(3),volumes(3),girths(3));
fprintf('%11.3f\t%10.3f\t%11.3f\t%13.3f\t%10.3f\n',lengths(4),widths(4),heights(4),volumes(4),girths(4));
