>> x=[0,1,2,3,4] x = 0 1 2 3 4 >> y=[2.31,4.99,7.73,10.42,13.10] y = 2.3100 4.9900 7.7300 10.4200 13.1000 >> plot(x,y,'*') >> n=5 n = 5 >> u=[1,1,1,1,1] u = 1 1 1 1 1 >> A=[x.^2*u', x*u'; x*u', n] A = 30 10 10 5 >> r=[(x.*y)*u'; y*u'] r = 104.1100 38.5500 >> inv(A)*r ans = 2.7010 2.3080 >> polyfit(x,y,1) ans = 2.7010 2.3080 >> hold Current plot held >> plot(x,2.710*x+2.3080) >> y-(x*2.710+2.3080) ans = 0.0020 -0.0280 0.0020 -0.0180 -0.0480 >> y=[-14-1/60-30.3/3600, -13-59/60-21.7/3600, -13-57/60-16.0/3600, -13-55/60-08.4/3600, -13-53/60-00.1/3600] y = -14.0251 -13.9894 -13.9544 -13.9190 -13.8834 >> hold Current plot released >> plot(x,y,'*') >> hold Current plot held >> polyfit(x,y,1) ans = 0.0354 -14.0250 >> plot(x,0.0354*x-14.0250) >> y-(x*0.0354-14.0250) ans = 1.0e-03 * -0.0833 0.2389 -0.2444 -0.2000 0.0389 >>