pause on
[r c]=size(weight);

A=ones(r,2);
A(:,2)=weight;
b=mpg;
x=A\b;

errorlinear=norm(A*x-b)

xplot=[1.5:.1:5];
yplot=x(1)+x(2)*xplot;
plot(weight,mpg,'*r',xplot,yplot)

pause

A=ones(r,3);
A(:,2)=weight;
A(:,3)=weight.^2;
b=mpg;
x=A\b;

errorquad=norm(A*x-b)

xplot=[1.5:.1:5];
yplot=x(1)+x(2)*xplot+x(3)*xplot.^2;
plot(weight,mpg,'*r',xplot,yplot)
