function fitLine
% fitLine  Demonstrate least squares fit of a line to data

% -- Store the data set
x = 1:8;
y = [4.41  6.82  7.07  12.02  13.97 20.77 20.87  25.17];

% -- Polyfit is built-in command to compute polynomial curve fit
c = polyfit(x,y,1);

% -- Generate data to evalute the fit over the range of the data
xfit = [min(x) max(x)];
yfit = polyval(c,xfit);

% -- Plot the data and the curve fit
plot(x,y,'o',xfit,yfit,'r--');
legend('Data','Line fit','Location','northwest')

% -- Evaluate the residual of the fit at the data points
% rfit = %% INSERT YOUR CODE HERE
% fprintf('Least squares fit has residual   = %12.3e\n',rfit);

end