% Script file to make a table of average speeds of objects in % free fall over progressively shorter time intervals. % The table includes columns for two different start times. % Display column headings % Note the special newline code '\n'. fprintf('Length of Average speed Average speed\n'); fprintf('interval h over [1, 1+h] over [2, 2+h]\n'); % Create table entries for n = 0:5 h = 10^(-n); % %10.5f is a formatting placeholder. It's filled in by % the value of h using a field width of 10, and 5 digits % after the decimal point. % The two occurences of %13.5f are replaced by the values % of avgSpeed(1,h) and avgSpeed(2,h) in fields of width 13 % with 5 digits after each decimal point. % \t stands for tab, and \n for newline. fprintf('%10.5f\t%13.5f\t%13.5f\n', h, avgSpeed(1,h), avgSpeed(2,h)); end