diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /243/CH10 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '243/CH10')
-rwxr-xr-x | 243/CH10/EX10.1/10_01.sce | 14 | ||||
-rwxr-xr-x | 243/CH10/EX10.2/10_02.sce | 18 | ||||
-rwxr-xr-x | 243/CH10/EX10.3/10_03.sce | 19 | ||||
-rwxr-xr-x | 243/CH10/EX10.4/10_4.sce | 20 | ||||
-rwxr-xr-x | 243/CH10/EX10.5/10_5.sce | 18 |
5 files changed, 89 insertions, 0 deletions
diff --git a/243/CH10/EX10.1/10_01.sce b/243/CH10/EX10.1/10_01.sce new file mode 100755 index 000000000..671b56567 --- /dev/null +++ b/243/CH10/EX10.1/10_01.sce @@ -0,0 +1,14 @@ +//Example No. 10_01
+//Fitting a Straight Line
+//Pg No. 326
+clear ;close ;clc ;
+
+x = poly(0,'x')
+X = 1:5
+Y = [ 3 4 5 6 8 ];
+n = length(X);
+b = ( n*sum(X.*Y) - sum(X)*sum(Y) )/( n*sum(X.*X) - (sum(X))^2 )
+a = sum(Y)/n - b*sum(X)/n
+disp(b,'b = ')
+disp(a,'a = ')
+y = a + b*x
diff --git a/243/CH10/EX10.2/10_02.sce b/243/CH10/EX10.2/10_02.sce new file mode 100755 index 000000000..72fd3e45c --- /dev/null +++ b/243/CH10/EX10.2/10_02.sce @@ -0,0 +1,18 @@ +//Example No. 10_02
+//Fitting a Power-Function model to given data
+//Pg No. 331
+clear ;close ;clc ;
+
+x = poly(0,'x');
+X = 1:5
+Y = [ 0.5 2 4.5 8 12.5 ]
+Xnew = log(X)
+Ynew = log(Y)
+n = length(Xnew)
+b = ( n*sum(Xnew.*Ynew) - sum(Xnew)*sum(Ynew) )/( n*sum(Xnew.*Xnew) - ( sum(Xnew) )^2 )
+lna = sum(Ynew)/n - b*sum(Xnew)/n
+a = exp(lna)
+disp(b,'b = ')
+disp(lna,'lna = ')
+disp(a,'a = ')
+printf('\n The power function equation obtained is \n y = %.4Gx^%.4G',a,b);
diff --git a/243/CH10/EX10.3/10_03.sce b/243/CH10/EX10.3/10_03.sce new file mode 100755 index 000000000..f67c21414 --- /dev/null +++ b/243/CH10/EX10.3/10_03.sce @@ -0,0 +1,19 @@ +//Example No. 10_03
+//Pg No. 332
+clear ;close ;clc ;
+
+time = 1:4
+T = [ 70 83 100 124 ]
+t = 6
+Fx = exp(time/4)
+n = length(Fx)
+Y = T ;
+b = ( n*sum(Fx.*Y) - sum(Fx)*sum(Y) )/( n*sum(Fx.*Fx) - (sum(Fx))^2 )
+a = sum(Y)/n - b*sum(Fx)/n
+disp(b,'b = ')
+disp(a,'a = ')
+printf('The relationship between T and t is \n T = %.4G*e^(t/4) + %.4G \n',b,a)
+deff('T = T(t)','T = b*exp(t/4) + a ')
+T_6 = T(6)
+
+disp(T_6,'The temperature at t = 6 is')
\ No newline at end of file diff --git a/243/CH10/EX10.4/10_4.sce b/243/CH10/EX10.4/10_4.sce new file mode 100755 index 000000000..67f00469f --- /dev/null +++ b/243/CH10/EX10.4/10_4.sce @@ -0,0 +1,20 @@ +//Example No. 10_04
+//Curve Fitting
+//Pg NO. 335
+clear ; close ; clc ;
+
+x = 1:4 ;
+y = [6 11 18 27 ];
+n = length(x) //Number of data points
+m = 2+1 //Number of unknowns
+disp('Using CA = B form , we get')
+for j = 1:m
+ for k = 1:m
+ C(j,k) = sum(x.^(j+k-2))
+ end
+ B(j) = sum( y.*( x.^( j-1 ) ) )
+end
+disp(B,'B = ',C,'C = ')
+A = inv(C)*B
+disp(A,'A = ')
+printf('Therefore the least sqaures polynomial is\n y = %i + %i*x + %i*x^2 \n',A(1),A(2),A(3))
\ No newline at end of file diff --git a/243/CH10/EX10.5/10_5.sce b/243/CH10/EX10.5/10_5.sce new file mode 100755 index 000000000..578cc3880 --- /dev/null +++ b/243/CH10/EX10.5/10_5.sce @@ -0,0 +1,18 @@ +//Example No. 10_05
+//Plane Fitting
+//Pg No. 342
+clear ; close ; clc ;
+
+x = 1:4
+z = 0:3
+y = 12:6:30
+n = length(x) //Number of data points
+m = 3 //Number of unknowns
+G = [ ones(1,n) ; x ; z]
+H = G'
+C = G*H
+B = y*H
+D = C\B'
+disp(C,B)
+disp(D)
+mprintf('\n The regression plane is \n y = %i + %f*x + %i*z ',D(1),D(2),D(3))
\ No newline at end of file |