summaryrefslogtreecommitdiff
path: root/1592/CH9
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:38:01 +0530
committerprashantsinalkar2017-10-10 12:38:01 +0530
commitf35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch)
treeeb72842d800ac1233e9d890e020eac5fd41b0b1b /1592/CH9
parent7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff)
downloadScilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip
updated the code
Diffstat (limited to '1592/CH9')
-rwxr-xr-x1592/CH9/EX9.11/example_9_11.sce55
-rwxr-xr-x1592/CH9/EX9.3/example_9_3.sce52
-rwxr-xr-x1592/CH9/EX9.5/example_9_5.sce61
-rwxr-xr-x1592/CH9/EX9.6/example_9_6.sce51
4 files changed, 117 insertions, 102 deletions
diff --git a/1592/CH9/EX9.11/example_9_11.sce b/1592/CH9/EX9.11/example_9_11.sce
index cb72453e8..51fb4d676 100755
--- a/1592/CH9/EX9.11/example_9_11.sce
+++ b/1592/CH9/EX9.11/example_9_11.sce
@@ -1,25 +1,30 @@
-//Scilab Code for Example 9.11 of Signals and systems by
-//P.Ramakrishna Rao
-//Power Spectral Density
-clear;
-clc;
-clear f n;
-fo=2;
-n=1;
-RC=1/(2*%pi*10^3);
-w=4*%pi*10^3
-H=1/(1+%i*w*RC);
-disp(H,'H(f)');
-X=(abs(H))^2;
-for f=-5:5
- Pxx(n)=25*[delta(f-fo)+delta(f+fo)];
- Pyy(n)=X*Pxx(n);
- n=n+1;
-end
-disp(Pxx,'Pxx=');
-disp(Pyy,'Pyy=');
-f=-5:5;
-plot2d3(f,Pyy,-2);
-title('Power Spectral Density');
-ylabel('Pyy(f)');
-xlabel('f in Hz');
+//Scilab Code for Example 9.11 of Signals and systems by
+//P.Ramakrishna Rao
+//Power Spectral Density
+clear;
+clc;
+function [y]=delta(t)
+ if t==0
+ y=1
+else y=0
+ end
+endfunction
+fo=2;
+n=1;
+RC=1/(2*%pi*10^3);
+w=4*%pi*10^3
+H=1/(1+%i*w*RC);
+disp(H,'H(f)');
+X=(abs(H))^2;
+for f=-5:5
+ Pxx(n)=25*[delta(f-fo)+delta(f+fo)];
+ Pyy(n)=X*Pxx(n);
+ n=n+1;
+end
+disp(Pxx,'Pxx=');
+disp(Pyy,'Pyy=');
+f=-5:5;
+plot2d3(f,Pyy,-2);
+title('Power Spectral Density');
+ylabel('Pyy(f)');
+xlabel('f in Hz'); \ No newline at end of file
diff --git a/1592/CH9/EX9.3/example_9_3.sce b/1592/CH9/EX9.3/example_9_3.sce
index 9d6385185..bf4e494b9 100755
--- a/1592/CH9/EX9.3/example_9_3.sce
+++ b/1592/CH9/EX9.3/example_9_3.sce
@@ -1,23 +1,29 @@
-//Scilab Code for Example 9.3 of Signals and systems by
-//P.Ramakrishna Rao
-//Convolution of two signals
-clc;
-clear;
-n=1;
-for t=-5:0.1:5
- x(n)=-2*u(t-0.5)+2*u(t-1.5);
- y(n)=(t+1)*u(t+1)-(t+1)*u(t-2);
- n=n+1;
-end
-z=conv(x,y);
-t=-5:0.1:5;
-plot2d2(t,x,5);
-title('x(t)');
-figure(1);
-t=-5:0.1:5;
-plot2d(t,y,2);
-title('y(t)');
-figure(2);
-t=-10:0.1:10;
-plot2d(t,z,6);
-title('Convolution');
+//Scilab Code for Example 9.3 of Signals and systems by
+//P.Ramakrishna Rao
+//Convolution of two signals
+clc;
+clear;
+function [y]=u(t)
+ if t>=0
+ y=1
+else y=0
+ end
+endfunction
+n=1;
+for t=-5:0.1:5
+ x(n)=-2*u(t-0.5)+2*u(t-1.5);
+ y(n)=(t+1)*u(t+1)-(t+1)*u(t-2);
+ n=n+1;
+end
+z=conv(x,y);
+t=-5:0.1:5;
+plot2d2(t,x,5);
+title('x(t)');
+figure(1);
+t=-5:0.1:5;
+plot2d(t,y,2);
+title('y(t)');
+figure(2);
+t=-10:0.1:10;
+plot2d(t,z,6);
+title('Convolution'); \ No newline at end of file
diff --git a/1592/CH9/EX9.5/example_9_5.sce b/1592/CH9/EX9.5/example_9_5.sce
index 4e148ec35..7919c5b59 100755
--- a/1592/CH9/EX9.5/example_9_5.sce
+++ b/1592/CH9/EX9.5/example_9_5.sce
@@ -1,28 +1,33 @@
-//Scilab Code for Example 9.5 of Signals and systems by
-//P.Ramakrishna Rao
-clc;
-clear;
-clear z x y t T;
-n=1;
-for t=-10:0.01:10;
- x(n)=exp(-t)*u(t);
- n=n+1;
-end
-t=-10:0.01:10;
-plot(t,x);
-title('x(t)');
-n=1;
-for T=-10:0.1:0;
- z(n)=integrate('exp(-t)*exp(T-t)','t',0,1000);
- n=n+1;
-end
-n=1;
-for T=0.1:0.1:10;
- z(n+101)=integrate('exp(-t)*exp(T-t)','t',T,1000);
- n=n+1;
-end
-figure(1);
-T=-10:0.1:10;
-plot(T,z);
-title('Rxx(T)');
-xlabel('t in seconds');
+//Scilab Code for Example 9.5 of Signals and systems by
+//P.Ramakrishna Rao
+clc;
+clear;
+function [y]=u(t)
+ if t>=0
+ y=1
+else y=0
+ end
+endfunction
+n=1;
+for t=-10:0.01:10;
+ x(n)=exp(-t)*u(t);
+ n=n+1;
+end
+t=-10:0.01:10;
+plot(t,x);
+title('x(t)');
+n=1;
+for T=-10:0.1:0;
+ z(n)=integrate('exp(-t)*exp(T-t)','t',0,1000);
+ n=n+1;
+end
+n=1;
+for T=0.1:0.1:10;
+ z(n+101)=integrate('exp(-t)*exp(T-t)','t',T,1000);
+ n=n+1;
+end
+figure(1);
+T=-10:0.1:10;
+plot(T,z);
+title('Rxx(T)');
+xlabel('t in seconds'); \ No newline at end of file
diff --git a/1592/CH9/EX9.6/example_9_6.sce b/1592/CH9/EX9.6/example_9_6.sce
index 57cd4a8a9..a52510e23 100755
--- a/1592/CH9/EX9.6/example_9_6.sce
+++ b/1592/CH9/EX9.6/example_9_6.sce
@@ -1,26 +1,25 @@
-//Scilab Code for Example 9.6 of Signals and systems by
-//P.Ramakrishna Rao
-clc;
-clear;
-clear z x y t T;
-A=1;
-n=1;
-wo=2*%pi;
-theta=%pi/2;
-for t=-5:0.01:5;
- x(n)=A*cos(wo*t+theta);
- n=n+1;
-end
-t=-5:0.01:5;
-plot(t,x);
-title('x(t)');
-n=1;
-for T=-5:0.1:5;
- z(n)=(A^2/2)*cos(wo*T);
- n=n+1;
-end
-figure(1);
-T=-5:0.1:5;
-plot(T,z);
-title('Rxx(T)');
-xlabel('t in seconds')
+//Scilab Code for Example 9.6 of Signals and systems by
+//P.Ramakrishna Rao
+clc;
+clear;
+A=1;
+n=1;
+wo=2*%pi;
+theta=%pi/2;
+for t=-5:0.01:5;
+ x(n)=A*cos(wo*t+theta);
+ n=n+1;
+end
+t=-5:0.01:5;
+plot(t,x);
+title('x(t)');
+n=1;
+for T=-5:0.1:5;
+ z(n)=(A^2/2)*cos(wo*T);
+ n=n+1;
+end
+figure(1);
+T=-5:0.1:5;
+plot(T,z);
+title('Rxx(T)');
+xlabel('t in seconds') \ No newline at end of file