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 /964/CH19 | |
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 '964/CH19')
-rwxr-xr-x | 964/CH19/EX19.1/19_1.sce | 43 | ||||
-rwxr-xr-x | 964/CH19/EX19.2/19_2.sce | 16 | ||||
-rwxr-xr-x | 964/CH19/EX19.3/19_3.jpeg | bin | 0 -> 25156 bytes | |||
-rwxr-xr-x | 964/CH19/EX19.3/19_3.sce | 8 | ||||
-rwxr-xr-x | 964/CH19/EX19.4/19_4.sce | 18 | ||||
-rwxr-xr-x | 964/CH19/EX19.5/19_5.sce | 25 | ||||
-rwxr-xr-x | 964/CH19/EX19.5/19_5a.jpeg | bin | 0 -> 25867 bytes | |||
-rwxr-xr-x | 964/CH19/EX19.5/19_5b.jpeg | bin | 0 -> 24873 bytes | |||
-rwxr-xr-x | 964/CH19/EX19.6/19_6.sce | 20 |
9 files changed, 130 insertions, 0 deletions
diff --git a/964/CH19/EX19.1/19_1.sce b/964/CH19/EX19.1/19_1.sce new file mode 100755 index 000000000..abd1ff8b4 --- /dev/null +++ b/964/CH19/EX19.1/19_1.sce @@ -0,0 +1,43 @@ +clc;
+clear;
+function y=f(t)
+ y=1.7+cos(4.189*t+1.0472)
+endfunction
+deltat=0.15;
+t1=0;
+t2=1.35;
+omega=4.189;
+del=(t2-t1)/9;
+for i=1:10
+ t(i)=t1+del*(i-1);
+end
+sumy=0;
+suma=0;
+sumb=0;
+for i=1:10
+ y(i)=f(t(i));
+ a(i)=y(i)*cos(omega*t(i));
+ b(i)=y(i)*sin(omega*t(i));
+ sumy=sumy+y(i);
+ suma=suma+a(i);
+ sumb=sumb+b(i);
+end
+A0=sumy/10;
+A1=2*suma/10;
+B1=2*sumb/10;
+disp("The least square fit is y=A0+A1*cos(w0*t)+A2*sin(w0*t), where")
+disp(A0,"A0=")
+disp(A1,"A1=")
+disp(B1,"B1=")
+theta=atan(-B1/A1);
+C1=(A1^2 + B1^2)^0.5;
+disp("Alternatively, the least square fit can be expressed as")
+disp("y=A0+C1*cos(w0*t + theta), where")
+disp(A0,"A0=")
+disp(theta,"Theta=")
+disp(C1,"C1=")
+disp("Or")
+disp("y=A0+C1*sin(w0*t + theta + pi/2), where")
+disp(A0,"A0=")
+disp(theta,"Theta=")
+disp(C1,"C1=")
\ No newline at end of file diff --git a/964/CH19/EX19.2/19_2.sce b/964/CH19/EX19.2/19_2.sce new file mode 100755 index 000000000..e89dbbf72 --- /dev/null +++ b/964/CH19/EX19.2/19_2.sce @@ -0,0 +1,16 @@ +clc;
+clear;
+a0=0;
+//f(t)=-1 for -T/2 to -T/4
+//f(t)=1 for -T/4 to T/4
+//f(t)=-1 for T/4 to T/2
+//ak=2/T* (integration of f(t)*cos(w0*t) from -T/2 to T/2)
+//ak=2/T*((integration of f(t)*cos(w0*t) from -T/2 to -T/4) + (integration of f(t)*cos(w0*t) from -T/4 to T/4) + (integration of f(t)*cos(w0*t) from T/4 to T/2))
+//Therefore,
+//ak=4/(k*%pi) for k=1,5,9,.....
+//ak=-4/(k*%pi) for k=3,7,11,.....
+//ak=0 for k=even integers
+//similarly we find the b's.
+//all the b's=0
+disp("The fourier approximtion is:")
+disp("4/(%pi)*cos(w)*t) - 4/(3*%pi)*cos(3*(w)*t) + 4/(5*%pi)*cos(5*(w)*t) - 4/(7*%pi)*cos(7*(w)*t) + .....")
\ No newline at end of file diff --git a/964/CH19/EX19.3/19_3.jpeg b/964/CH19/EX19.3/19_3.jpeg Binary files differnew file mode 100755 index 000000000..bc0a63a88 --- /dev/null +++ b/964/CH19/EX19.3/19_3.jpeg diff --git a/964/CH19/EX19.3/19_3.sce b/964/CH19/EX19.3/19_3.sce new file mode 100755 index 000000000..4090562f0 --- /dev/null +++ b/964/CH19/EX19.3/19_3.sce @@ -0,0 +1,8 @@ +clc;
+clear;
+x=0.5:0.5:5.5;
+for i=1:11
+ y(i)=0.9846*ln(x(i))+1.0004;
+end
+plot(x,y)
+xtitle("y vs x","x","y")
\ No newline at end of file diff --git a/964/CH19/EX19.4/19_4.sce b/964/CH19/EX19.4/19_4.sce new file mode 100755 index 000000000..78c5f1fd1 --- /dev/null +++ b/964/CH19/EX19.4/19_4.sce @@ -0,0 +1,18 @@ +clc;
+clear;
+s=[0.0002 0.0002 0.0005 0.0005 0.001 0.001];
+r=[0.2 0.5 0.2 0.5 0.2 0.5];
+u=[0.25; 0.5; 0.4; 0.75; 0.5; 1];
+logs=log10(s);
+logr=log10(r);
+logu=log10(u);
+for i=1:6
+ m(i,1)=1;
+ m(i,2)=logs(i);
+ m(i,3)=logr(i);
+end
+
+a=m\logu;
+disp(10^a(1),"alpha=")
+disp(a(2),"sigma=")
+disp(a(3),"rho=")
\ No newline at end of file diff --git a/964/CH19/EX19.5/19_5.sce b/964/CH19/EX19.5/19_5.sce new file mode 100755 index 000000000..75a18d953 --- /dev/null +++ b/964/CH19/EX19.5/19_5.sce @@ -0,0 +1,25 @@ +clc;
+clear;
+x=0:10;
+y=sin(x);
+xi=0:.25:10;
+//part a
+yi=interp1(x,y,xi);
+plot2d(xi,yi)
+xtitle("y vs x (part a)","x","y")
+//part b
+//fitting x and y in a fifth order polynomial
+clf();
+p=[0.0008 -0.0290 0.3542 -1.6854 2.586 -0.0915];
+
+for i=1:41
+ yi(i)=p(1)*(xi(i)^5)+p(2)*(xi(i)^4)+p(3)*(xi(i)^3)+p(4)*(xi(i)^2)+p(5)*(xi(i))+p(6);
+end
+plot2d(xi,yi);
+xtitle("y vs x (part b)","x","y")
+//part c
+clf();
+d=splin(x,y)
+yi-interp(xi,x,y,d)
+plot2d(xi,yi)
+xtitle("y vs x (part c)","x","y")
diff --git a/964/CH19/EX19.5/19_5a.jpeg b/964/CH19/EX19.5/19_5a.jpeg Binary files differnew file mode 100755 index 000000000..abb4ab346 --- /dev/null +++ b/964/CH19/EX19.5/19_5a.jpeg diff --git a/964/CH19/EX19.5/19_5b.jpeg b/964/CH19/EX19.5/19_5b.jpeg Binary files differnew file mode 100755 index 000000000..0f1805feb --- /dev/null +++ b/964/CH19/EX19.5/19_5b.jpeg diff --git a/964/CH19/EX19.6/19_6.sce b/964/CH19/EX19.6/19_6.sce new file mode 100755 index 000000000..3d823cf1f --- /dev/null +++ b/964/CH19/EX19.6/19_6.sce @@ -0,0 +1,20 @@ +clc;
+clear;
+x=[0.05 0.12 0.15 0.3 0.45 0.7 0.84 1.05];
+y=[0.957 0.851 0.832 0.72 0.583 0.378 0.295 0.156];
+sx=sum(x);
+sxx=sum(x.*x);
+sx3=sum(x.*x.*x);
+sx4=sum(x.*x.*x.*x);
+sx5=sum(x.*x.*x.*x.*x);
+sx6=sum(x.*x.*x.*x.*x.*x);
+n=8;
+sy=sum(y);
+sxy=sum(x.*y);
+sx2y=sum(x.*x.*y);
+sx3y=sum(x.*x.*x.*y);
+m=[n sx sxx sx3;sx sxx sx3 sx4;sxx sx3 sx4 sx5;sx3 sx4 sx5 sx6];
+p=[sy;sxy;sx2y;sx3y];
+a=m\p;
+disp("The cubic polynomial is y=a0 + a1*x + a2*x^2 + a3*x^3, where a0, a1, a2 and a3 are")
+disp(a)
\ No newline at end of file |