a0=4 b=10 n=5 x=linspace(a0,b,n) B=linspace(x,x,3); C= ones(5,1) D=B(:,1) E=D.^2 A= [C D E] S= A'*A y=cos(x)' t=A'*y; a=S^(-1)*t xx=linspace(a0,b,40) p=a(1,1)*1+ a(2,1)*x+a(3,1)*x.^2 plot(x,y,'ro') hold on plot(xx,p,'o')
Standard input is empty
a0 = 4 b = 10 n = 5 x = 4.0000 5.5000 7.0000 8.5000 10.0000 C = 1 1 1 1 1 D = 4.0000 5.5000 7.0000 8.5000 10.0000 E = 16.000 30.250 49.000 72.250 100.000 A = 1.0000 4.0000 16.0000 1.0000 5.5000 30.2500 1.0000 7.0000 49.0000 1.0000 8.5000 72.2500 1.0000 10.0000 100.0000 S = 5.00000 35.00000 267.50000 35.00000 267.50000 2187.50000 267.50000 2187.50000 18792.12500 y = -0.65364 0.70867 0.75390 -0.60201 -0.83907 a = -5.83997 1.93229 -0.14603 xx = Columns 1 through 8: 4.0000 4.1538 4.3077 4.4615 4.6154 4.7692 4.9231 5.0769 Columns 9 through 16: 5.2308 5.3846 5.5385 5.6923 5.8462 6.0000 6.1538 6.3077 Columns 17 through 24: 6.4615 6.6154 6.7692 6.9231 7.0769 7.2308 7.3846 7.5385 Columns 25 through 32: 7.6923 7.8462 8.0000 8.1538 8.3077 8.4615 8.6154 8.7692 Columns 33 through 40: 8.9231 9.0769 9.2308 9.3846 9.5385 9.6923 9.8462 10.0000 p = -0.447251 0.370287 0.530697 0.033979 -1.119866
error: __plt2vv__: vector lengths must match error: called from __plt__>__plt2vv__ at line 483 column 5 __plt__>__plt2__ at line 242 column 14 __plt__ at line 107 column 17 plot at line 223 column 10 /home/LddAUk/prog.octave at line 20 column 4