load linefit.dat; x = linefit(:,1); y = linefit(:,2); figure(1), plot(x,y,'o'); % Use polyfit function to generate coefficiants for linear fit: pcoeff = polyfit(x,y,1); % Use this in polyval function to generate line: xp = linspace(0,7,100); yp = polyval(pcoeff,xp); figure(2), plot(x,y,'o',xp,yp,'m'); % Use polyfit function to generate coefficiants for QUADRATIC fit: pcoeff2 = polyfit(x,y,2); yp2 = polyval(pcoeff2,xp); figure(3), plot(x,y,'o',xp,yp2,'m') % Calculate the E2 error at specific data points: yp3 = polyval(pcoeff2,x); n = length(x); E2 = sqrt( sum( abs(yp3-y).^2)/n);