diff options
Diffstat (limited to '1592')
-rwxr-xr-x | 1592/CH1/EX1.11/Example1_11.sce | 82 | ||||
-rwxr-xr-x | 1592/CH1/EX1.7/Example1_7.sce | 74 | ||||
-rwxr-xr-x | 1592/CH10/EX10.11/example_10_11.sce | 45 | ||||
-rwxr-xr-x | 1592/CH10/EX10.5/example_10_5.sce | 47 | ||||
-rwxr-xr-x | 1592/CH10/EX10.8/example_10_8.sce | 47 | ||||
-rwxr-xr-x | 1592/CH11/EX11.1/example_11_1.sce | 41 | ||||
-rwxr-xr-x | 1592/CH6/EX6.1/Example_6_1.sce | 72 | ||||
-rwxr-xr-x | 1592/CH6/EX6.2/Example_6_2.sce | 94 | ||||
-rwxr-xr-x | 1592/CH6/EX6.5/Example_6_5.sce | 73 | ||||
-rwxr-xr-x | 1592/CH7/EX7.22/Example_7_22.sce | 79 | ||||
-rwxr-xr-x | 1592/CH7/EX7.23/Example_7_23.sce | 77 | ||||
-rwxr-xr-x | 1592/CH9/EX9.11/example_9_11.sce | 55 | ||||
-rwxr-xr-x | 1592/CH9/EX9.3/example_9_3.sce | 52 | ||||
-rwxr-xr-x | 1592/CH9/EX9.5/example_9_5.sce | 61 | ||||
-rwxr-xr-x | 1592/CH9/EX9.6/example_9_6.sce | 51 |
15 files changed, 506 insertions, 444 deletions
diff --git a/1592/CH1/EX1.11/Example1_11.sce b/1592/CH1/EX1.11/Example1_11.sce index ade4e6a1a..5aefda4cd 100755 --- a/1592/CH1/EX1.11/Example1_11.sce +++ b/1592/CH1/EX1.11/Example1_11.sce @@ -1,38 +1,44 @@ -//Scilab Code for Example 1.11 of Signals and systems by
-//P.Ramakrishna Rao
-//displaying plots for the given signals
-clear;
-clc;
-for t=-3:1:3
-y(t+4)=abs(t+3)*u(t+3)-abs(t+1)*u(t+1)-abs(t-1)*u(t-1)+abs(t-3)*u(t-3);
-end
-t=-3:1:3;
-//for the main given signal
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot(t,y);
-title('Main Signal)');
-dy=0*y;
-for i=1:6
-dy(i)=(y(i+1)-y(i))/1;
-end
-//for the derivative of the given signal
-figure(1);
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d2(t,dy);
-title('Derivative of Signal');
-dy2=0*dy;
-dy2(1)=dy(1)-0;
-for i=1:6
-dy2(i+1)=(dy(i+1)-dy(i))/1;
-end
-//for the impulse response representation or second derivative
-figure(2);
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d3(t,dy2,-5);
-title('Impulse response representation');
+//Scilab Code for Example 1.11 of Signals and systems by +//P.Ramakrishna Rao +//displaying plots for the given signals +clear; +clc; +function [y]=u(t) + if t>=0 + y=1 +else y=0 + end +endfunction +for t=-3:1:3 +y(t+4)=abs(t+3)*u(t+3)-abs(t+1)*u(t+1)-abs(t-1)*u(t-1)+abs(t-3)*u(t-3); +end +t=-3:1:3; +//for the main given signal +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot(t,y); +title('Main Signal)'); +dy=0*y; +for i=1:6 +dy(i)=(y(i+1)-y(i))/1; +end +//for the derivative of the given signal +figure(1); +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d2(t,dy); +title('Derivative of Signal'); +dy2=0*dy; +dy2(1)=dy(1)-0; +for i=1:6 +dy2(i+1)=(dy(i+1)-dy(i))/1; +end +//for the impulse response representation or second derivative +figure(2); +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d3(t,dy2,-5); +title('Impulse response representation');
\ No newline at end of file diff --git a/1592/CH1/EX1.7/Example1_7.sce b/1592/CH1/EX1.7/Example1_7.sce index e6f31fdfa..955fcf848 100755 --- a/1592/CH1/EX1.7/Example1_7.sce +++ b/1592/CH1/EX1.7/Example1_7.sce @@ -1,34 +1,40 @@ -//Scilab Code for Example 1.7 of Signals and systems by
-//P.Ramakrishna Rao
-clear;
-clc;
-n=1;
-for t=-10:0.1:10;
- //Function for Even signal
- y1(n)=0.5*(exp(-t)*u(t)+exp(t)*u(-t));
- n=n+1;
-end
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-t=-10:0.1:10;
-//Plot of Even Signal
-plot(t,y1);
-title('y1(t)');
-xlabel('Time in seconds');
-n=1;
-for t=-1:0.01:1;
- //Function for Odd signal
- y2(n)=0.5*(exp(-t)*u(t)-exp(t)*u(-t));
- n=n+1;
-end
-figure(1);
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-t=-1:0.01:1;
-//Plot of Odd Signal
-plot(t,y2)
-disp('plotted the signal both in even and odd forms');
-title('y2(t)');
-xlabel('Time in seconds');
+//Scilab Code for Example 1.7 of Signals and systems by +//P.Ramakrishna Rao +clear; +clc; +function [y]=u(t) + if t>=0 + y=1 +else y=0 + end +endfunction +n=1; +for t=-10:0.1:10; + //Function for Even signal + y1(n)=0.5*(exp(-t)*u(t)+exp(t)*u(-t)); + n=n+1; +end +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +t=-10:0.1:10; +//Plot of Even Signal +plot(t,y1); +title('y1(t)'); +xlabel('Time in seconds'); +n=1; +for t=-1:0.01:1; + //Function for Odd signal + y2(n)=0.5*(exp(-t)*u(t)-exp(t)*u(-t)); + n=n+1; +end +figure(1); +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +t=-1:0.01:1; +//Plot of Odd Signal +plot(t,y2) +disp('plotted the signal both in even and odd forms'); +title('y2(t)'); +xlabel('Time in seconds');
\ No newline at end of file diff --git a/1592/CH10/EX10.11/example_10_11.sce b/1592/CH10/EX10.11/example_10_11.sce index e2f72428c..70ca8ea2f 100755 --- a/1592/CH10/EX10.11/example_10_11.sce +++ b/1592/CH10/EX10.11/example_10_11.sce @@ -1,23 +1,22 @@ -//Scilab Code for Example 10.11 of Signals and systems by
-//P.Ramakrishna Rao
-//System Identification
-//Cross Correlation
-clear;
-clc;
-clear x n a y h z;
-x=[1,1,1,1,0,0];
-y=[1,3,6,10,12,12,10,6,3,1];
-h(1)=y(1)/x(1);
-for n=2:7
- for k=1:n-1
- z(k)=(h(k)*x(n-k));
- h(n)=(y(n)-sum(z));
- end
-end
-disp(h,'h(n)');
-n=1:7;
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d3(n,h,-4);
-title('System Response h(n)');
+//Scilab Code for Example 10.11 of Signals and systems by +//P.Ramakrishna Rao +//System Identification +//Cross Correlation +clear; +clc; +x=[1,1,1,1,0,0]; +y=[1,3,6,10,12,12,10,6,3,1]; +h(1)=y(1)/x(1); +for n=2:7 + for k=1:n-1 + z(k)=(h(k)*x(n-k)); + h(n)=(y(n)-sum(z)); + end +end +disp(h,'h(n)'); +n=1:7; +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d3(n,h,-4); +title('System Response h(n)');
\ No newline at end of file diff --git a/1592/CH10/EX10.5/example_10_5.sce b/1592/CH10/EX10.5/example_10_5.sce index 7c4224bb5..561e70462 100755 --- a/1592/CH10/EX10.5/example_10_5.sce +++ b/1592/CH10/EX10.5/example_10_5.sce @@ -1,21 +1,26 @@ -//Scilab Code for Example 10.5 of Signals and systems by
-//P.Ramakrishna Rao
-//Auto Correlation
-clear;
-clc;
-clear x n a;
-k=1;
-a=0.8;
-for n=-30:30;
- x(k)=a^(-n)*u(-n);
- k=k+1;
-end
-length(x)
-//computation of auto correlation sequence;
-r = xcorr(x);
-n=-60:60;
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d3(n,r,-4);
-title('rxx_auto-correlation');
+//Scilab Code for Example 10.5 of Signals and systems by +//P.Ramakrishna Rao +//Auto Correlation +clear; +clc; +function [y]=u(t) + if t>=0 + y=1 +else y=0 + end +endfunction +k=1; +a=0.8; +for n=-30:30; + x(k)=a^(-n)*u(-n); + k=k+1; +end +length(x) +//computation of auto correlation sequence; +r = xcorr(x); +n=-60:60; +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d3(n,r,-4); +title('rxx_auto-correlation');
\ No newline at end of file diff --git a/1592/CH10/EX10.8/example_10_8.sce b/1592/CH10/EX10.8/example_10_8.sce index e5f1e553c..bc7464bb9 100755 --- a/1592/CH10/EX10.8/example_10_8.sce +++ b/1592/CH10/EX10.8/example_10_8.sce @@ -1,21 +1,26 @@ -//Scilab Code for Example 10.8 of Signals and systems by
-//P.Ramakrishna Rao
-//Auto Correlation
-clear;
-clc;
-clear x n a;
-k=1;
-a=0.8;
-for n=-30:30;
- x(k)=a^(n)*u(n);
- k=k+1;
-end
-length(x)
-//computation of auto correlation sequence;
-r = xcorr(x);
-n=-60:60;
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d3(n,r,-4);
-title('rxx_auto-correlation');
+//Scilab Code for Example 10.8 of Signals and systems by +//P.Ramakrishna Rao +//Auto Correlation +clear; +clc; +function [y]=u(t) + if t>=0 + y=1 +else y=0 + end +endfunction +k=1; +a=0.8; +for n=-30:30; + x(k)=a^(n)*u(n); + k=k+1; +end +length(x) +//computation of auto correlation sequence; +r = xcorr(x); +n=-60:60; +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d3(n,r,-4); +title('rxx_auto-correlation');
\ No newline at end of file diff --git a/1592/CH11/EX11.1/example_11_1.sce b/1592/CH11/EX11.1/example_11_1.sce index f694b5da7..d72cf6b70 100755 --- a/1592/CH11/EX11.1/example_11_1.sce +++ b/1592/CH11/EX11.1/example_11_1.sce @@ -1,21 +1,20 @@ -//Scilab Code for Example 11.1 of Signals and systems by
-//P.Ramakrishna Rao
-//Hilbert Transform
-clc;
-clear;
-n=1;
-for t=-1:0.01:1
- xr(n)=sin(2*%pi*t);
- n=n+1;
-end
-//Computing Hilbertb Transform
-x=hilbert(xr);
-t=-1:0.01:1;
-plot(t,xr);
-title('Given Signal x(t)');
-xlabel('time t-->');
-figure(1);
-t=-1:0.1:1;
-plot(t,imag(x));
-title('Hilbert Transform');
-xlabel('time t-->');
+//Scilab Code for Example 11.1 of Signals and systems by +//P.Ramakrishna Rao +//Hilbert Transform +clc; +clear; +n=1; +for t=-1:0.01:1 + xr(n)=sin(2*%pi*t); + n=n+1; +end +//Computing Hilbertb Transform +x=hilbert(xr); +plot(t,xr); +title('Given Signal x(t)'); +xlabel('time t-->'); +figure(1); +t=-1:0.1:1; +plot(t,imag(x)); +title('Hilbert Transform'); +xlabel('time t-->');
\ No newline at end of file diff --git a/1592/CH6/EX6.1/Example_6_1.sce b/1592/CH6/EX6.1/Example_6_1.sce index 6dfef7a58..c9e89c3fb 100755 --- a/1592/CH6/EX6.1/Example_6_1.sce +++ b/1592/CH6/EX6.1/Example_6_1.sce @@ -1,33 +1,39 @@ -//Scilab Code for Example 6.1 of Signals and systems by
-//P.Ramakrishna Rao
-//Sampling of signal
-clc;
-clear f n X X_delta w;
-fs=200;
-for f=-200:200
- X(f+201)=5*[delta(f-75)+delta(f+75)];
-end
-figure(1);
-f=-200:200;
-plot2d3(f,X,-2);
-title('X(f)');
-xlabel('---> f');
-w=1;
-n=-1;
- for f=-275:275
- X_delta1(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
- end
-n=n+1;
- for f=-275:275
- X_delta2(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-n=n+1;
- for f=-275:275
- X_delta3(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-X_delta=X_delta1+X_delta2+X_delta3;
-figure(2);
-f=-275:275;
-plot2d3(f,X_delta,-2);
-title('X_delta(f) at fs=200');
-xlabel('---> f');
+//Scilab Code for Example 6.1 of Signals and systems by +//P.Ramakrishna Rao +//Sampling of signal +clc; +clear +function [y]=delta(t) + if t==0 + y=1 +else y=0 + end +endfunction +fs=200; +for f=-200:200 + X(f+201)=5*[delta(f-75)+delta(f+75)]; +end +figure(1); +f=-200:200; +plot2d3(f,X,-2); +title('X(f)'); +xlabel('---> f'); +w=1; +n=-1; + for f=-275:275 + X_delta1(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; + end +n=n+1; + for f=-275:275 + X_delta2(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +n=n+1; + for f=-275:275 + X_delta3(f+276)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +X_delta=X_delta1+X_delta2+X_delta3; +figure(2); +f=-275:275; +plot2d3(f,X_delta,-2); +title('X_delta(f) at fs=200'); +xlabel('---> f');
\ No newline at end of file diff --git a/1592/CH6/EX6.2/Example_6_2.sce b/1592/CH6/EX6.2/Example_6_2.sce index 2b43c42a8..671d6d061 100755 --- a/1592/CH6/EX6.2/Example_6_2.sce +++ b/1592/CH6/EX6.2/Example_6_2.sce @@ -1,44 +1,50 @@ -//Scilab Code for Example 6.2 of Signals and systems by
-//P.Ramakrishna Rao
-//Sampling of signal and aliasing due to low Sampling frequency
-clc;
-clear f n X X_delta X_delta1 X_delta2 X_delta3 w;
-fs=100;
-for f=-200:200
- X(f+201)=5*[delta(f-75)+delta(f+75)];
-end
-figure(1);
-f=-200:200;
-plot2d3(f,X,-2);
-title('X(f)');
-xlabel('---> f');
-w=1;
-n=-2;
- for f=-175:175
- X_delta1(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
- end
-n=n+1;
- for f=-175:175
- X_delta2(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-n=n+1;
- for f=-175:175
- X_delta3(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-n=n+1;
- for f=-175:175
- X_delta4(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-n=n+1;
- for f=-175:175
- X_delta5(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)];
-end
-X_delta=X_delta1+X_delta2+X_delta3+X_delta4+X_delta5;
-figure(2);
-f=-175:175;
-
-plot2d3(f,X_delta,-2);
-title('X_delta(f) at fs=100');
-xlabel('---> f');
-//The Presence of the 25 HZ component in the spectrum of x_delta(t)
-//Due to effect of Aliasing
+//Scilab Code for Example 6.2 of Signals and systems by +//P.Ramakrishna Rao +//Sampling of signal and aliasing due to low Sampling frequency +clc; +clear +function [y]=delta(t) + if t==0 + y=1 +else y=0 + end +endfunction +fs=100; +for f=-200:200 + X(f+201)=5*[delta(f-75)+delta(f+75)]; +end +figure(1); +f=-200:200; +plot2d3(f,X,-2); +title('X(f)'); +xlabel('---> f'); +w=1; +n=-2; + for f=-175:175 + X_delta1(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; + end +n=n+1; + for f=-175:175 + X_delta2(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +n=n+1; + for f=-175:175 + X_delta3(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +n=n+1; + for f=-175:175 + X_delta4(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +n=n+1; + for f=-175:175 + X_delta5(f+176)=fs*5*[delta(f-n*fs-75)+delta(f-n*fs+75)]; +end +X_delta=X_delta1+X_delta2+X_delta3+X_delta4+X_delta5; +figure(2); +f=-175:175; + +plot2d3(f,X_delta,-2); +title('X_delta(f) at fs=100'); +xlabel('---> f'); +//The Presence of the 25 HZ component in the spectrum of x_delta(t) +//Due to effect of Aliasing
\ No newline at end of file diff --git a/1592/CH6/EX6.5/Example_6_5.sce b/1592/CH6/EX6.5/Example_6_5.sce index d42c30e70..0de268f04 100755 --- a/1592/CH6/EX6.5/Example_6_5.sce +++ b/1592/CH6/EX6.5/Example_6_5.sce @@ -1,34 +1,39 @@ -//Scilab Code for Example 6.5 of Signals and systems by
-//P.Ramakrishna Rao//Output of LPF
-clc;
-clear;
-
-for f=-100:100
- X(f+101)=delta(f+100)+delta(f-100)+3*[delta(f+90)+delta(f-90)];
-end
-f=-100:100;
-a=gca();
-a.x_location="origin";
-a.y_location="origin";
-plot2d3(f,X,-2);
-title('Spectrum of x(t)');
-xlabel('--> f');
-fs=150;
-n=-1;f-n*fs
- for f=-275:275
- X_delta1(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)];
- end
-n=n+1;
- for f=-275:275
- X_delta2(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)];
-end
-n=n+1;
- for f=-275:275
- X_delta3(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)];
-end
-X_delta=X_delta1+X_delta2+X_delta3;
-figure(2);
-f=-275:275;
-plot2d3(f,X_delta,-2);
-title('X_delta(f) at fs=150');
-xlabel('---> f');
+//Scilab Code for Example 6.5 of Signals and systems by +//P.Ramakrishna Rao//Output of LPF +clc; +clear; +function [y]=delta(t) + if t==0 + y=1 +else y=0 + end +endfunction +for f=-100:100 + X(f+101)=delta(f+100)+delta(f-100)+3*[delta(f+90)+delta(f-90)]; +end +f=-100:100; +a=gca(); +a.x_location="origin"; +a.y_location="origin"; +plot2d3(f,X,-2); +title('Spectrum of x(t)'); +xlabel('--> f'); +fs=150; +n=-1;f-n*fs + for f=-275:275 + X_delta1(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)]; + end +n=n+1; + for f=-275:275 + X_delta2(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)]; +end +n=n+1; + for f=-275:275 + X_delta3(f+276)=delta(f-n*fs+100)+delta(f-n*fs-100)+3*[delta(f-n*fs+90)+delta(f-n*fs-90)]; +end +X_delta=X_delta1+X_delta2+X_delta3; +figure(2); +f=-275:275; +plot2d3(f,X_delta,-2); +title('X_delta(f) at fs=150'); +xlabel('---> f');
\ No newline at end of file diff --git a/1592/CH7/EX7.22/Example_7_22.sce b/1592/CH7/EX7.22/Example_7_22.sce index e063736b4..d9e629f89 100755 --- a/1592/CH7/EX7.22/Example_7_22.sce +++ b/1592/CH7/EX7.22/Example_7_22.sce @@ -1,37 +1,42 @@ -//Scilab Code for Example 7.22 of Signals and systems by
-//P.Ramakrishna Rao
-//Convolution of two signals
-clc;
-clear;
-clear x y n;
-for n=0:10;
- x(n+1)=(3/4)^n*u(n);
-end
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-n=0:10;
-plot2d3(n,x,-4);
-title('x(n)')
-xlabel('n')
-for n=0:10;
- y(n+1)=u(n);
-end
-figure(1);
-n=0:10;
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-plot2d3(n,y,-4);
-title('y(k)')
-xlabel('k')
-z=conv(x,y);
-figure(2);
-n=0:20;
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-plot2d3(n,z,-4);
-title('Convoluted signal w(t)');
-xlabel('t');
-disp(z(1),'z(0)',z(4),'z(3)',z(6),'z(5)',z(11),'z(10)');
+//Scilab Code for Example 7.22 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 +for n=0:10; + x(n+1)=(3/4)^n*u(n); +end +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +n=0:10; +plot2d3(n,x,-4); +title('x(n)') +xlabel('n') +for n=0:10; + y(n+1)=u(n); +end +figure(1); +n=0:10; +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +plot2d3(n,y,-4); +title('y(k)') +xlabel('k') +z=conv(x,y); +figure(2); +n=0:20; +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +plot2d3(n,z,-4); +title('Convoluted signal w(t)'); +xlabel('t'); +disp(z(1),'z(0)',z(4),'z(3)',z(6),'z(5)',z(11),'z(10)');
\ No newline at end of file diff --git a/1592/CH7/EX7.23/Example_7_23.sce b/1592/CH7/EX7.23/Example_7_23.sce index b24378108..44dd336f5 100755 --- a/1592/CH7/EX7.23/Example_7_23.sce +++ b/1592/CH7/EX7.23/Example_7_23.sce @@ -1,36 +1,41 @@ -//Scilab Code for Example 7.23 of Signals and systems by
-//P.Ramakrishna Rao
-//Convolution of two signals
-clc;
-clear;
-clear x y n;
-for n=0:10;
- x(n+1)=(0.5)^n*u(n-2);
-end
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-n=0:10;
-plot2d3(n,x,-4);
-title('x(n)')
-xlabel('n')
-for n=0:10;
- y(n+1)=u(n);
-end
-figure(1);
-n=0:10;
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-plot2d3(n,y,-4);
-title('y(k)')
-xlabel('k')
-z=conv(x,y);
-figure(2);
-n=0:20;
-c = gca();
-c.y_location = "origin";
-c.x_location = "origin";
-plot2d3(n,z,-4);
-title('Convoluted signal z(t)')
-xlabel('t')
+//Scilab Code for Example 7.23 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 +for n=0:10; + x(n+1)=(0.5)^n*u(n-2); +end +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +n=0:10; +plot2d3(n,x,-4); +title('x(n)') +xlabel('n') +for n=0:10; + y(n+1)=u(n); +end +figure(1); +n=0:10; +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +plot2d3(n,y,-4); +title('y(k)') +xlabel('k') +z=conv(x,y); +figure(2); +n=0:20; +c = gca(); +c.y_location = "origin"; +c.x_location = "origin"; +plot2d3(n,z,-4); +title('Convoluted signal z(t)') +xlabel('t')
\ No newline at end of file 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 |