diff options
Diffstat (limited to '1670/CH6/EX6.12/6_12.sce')
-rwxr-xr-x | 1670/CH6/EX6.12/6_12.sce | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/1670/CH6/EX6.12/6_12.sce b/1670/CH6/EX6.12/6_12.sce new file mode 100755 index 000000000..bc040078d --- /dev/null +++ b/1670/CH6/EX6.12/6_12.sce @@ -0,0 +1,27 @@ +//Example 6.12
+//Least Square Fit
+//Page no. 224
+clc;close;clear;
+
+x=[10,20,30,40,50]
+y=[8,10,15,21,30]
+n=1;
+printf('\t\t 2\t 4\t\t\t 2\n n\tx\tx\tx\t\ty\tx y\n----------------------------------------------------------------\n')
+x1=0;x2=0;x3=0;x4=0;x5=0;x6=0;x7=0;x8=0;
+for i=1:5
+ printf(' %g\t%g\t%g\t%.9g\t\t%g\t%g\n',n,x(i),x(i)^2,x(i)^4,y(i),x(i)^2*y(i))
+ x1=x1+n;
+ x2=x2+x(i);
+ x3=x3+x(i)^2;
+ x4=x4+x(i)^4;
+ x5=x5+y(i);
+ x6=x6+x(i)^2*y(i)
+end
+printf('----------------------------------------------------------------\n %g\t%g\t%g\t%.9g\t\t%g\t%g\n',x1,x2,x3,x4,x5,x6)
+A=[x1,x3;x3,x4;]
+B=[x5;x6]
+C=inv(A)*B;
+disp(C)
+x=poly(0,'x')
+y=C(1)+C(2)*x^2
+disp(y,'y =')
\ No newline at end of file |