summaryrefslogtreecommitdiff
path: root/Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb
diff options
context:
space:
mode:
authorprashantsinalkar2020-04-14 10:19:27 +0530
committerprashantsinalkar2020-04-14 10:23:54 +0530
commit476705d693c7122d34f9b049fa79b935405c9b49 (patch)
tree2b1df110e24ff0174830d7f825f43ff1c134d1af /Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb
parentabb52650288b08a680335531742a7126ad0fb846 (diff)
downloadall-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.gz
all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.bz2
all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.zip
Initial commit
Diffstat (limited to 'Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb')
-rw-r--r--Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb858
1 files changed, 858 insertions, 0 deletions
diff --git a/Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb b/Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb
new file mode 100644
index 0000000..f82df0a
--- /dev/null
+++ b/Signals_And_Systems_by_P_R_Rao/7-Systems.ipynb
@@ -0,0 +1,858 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 7: Systems"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.10: Output_of_an_LTI.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.10 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clear;\n",
+"clc;\n",
+"disp('h(t)=e^-2*t.u(t)');\n",
+"for w=1:100\n",
+" y(1,w)=integrate('exp(-2*t)','t',0,w);\n",
+"end\n",
+"w=1:100;\n",
+"plot(w,y)\n",
+"title('Output Signal y(t)');\n",
+"xlabel('Time');\n",
+"ylabel('Amplitude');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.11: Convolution.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.11 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clear;\n",
+"clc;\n",
+"clear x y n;\n",
+"x=[0,0,2,0,0];\n",
+"y=[0,0,1,1,0];\n",
+"n=-2:2;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d2(n,x,2);\n",
+"title('x(t)')\n",
+"xlabel('t')\n",
+"figure(1);\n",
+"n=-2:2;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d2(n,y,5);\n",
+"title('y(t)')\n",
+"xlabel('t')\n",
+"z=conv(x,y);\n",
+"figure(2);\n",
+"n=-3:5;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot(n,z,2);\n",
+"title('Convoluted signal z(t)')\n",
+"xlabel('t')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.14: Impulse_and_Step_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.14 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Plotting the impulse and step responses\n",
+"clc;\n",
+"clear;\n",
+"syms s t R C;\n",
+"Y1=(1/(R*C))/(s+1/(R*C));\n",
+"disp(Y1,'Laplace Transform Of differential Equation is:')\n",
+"y11=ilaplace(Y1,s,t);\n",
+"disp(y11,'The Impulse Response of the System is:');\n",
+"for k=0:10;\n",
+" y1(k+1)=exp(-k);\n",
+"end\n",
+"k=0:10;\n",
+"plot(k,y1);\n",
+"title('System Response to impulse input');\n",
+"Y2=(1/(R*C))/(s^2+s/(R*C));\n",
+"disp(Y2,'Laplace Transform Of differential Equation is:')\n",
+"y22=ilaplace(Y2,s,t);\n",
+"disp(y22,'The Step Response of the System is:');\n",
+"for k=0:10;\n",
+" y2(k+1)=1-exp(-k);\n",
+"end\n",
+"figure(1);\n",
+"k=0:10;\n",
+"plot(k,y2);\n",
+"title('System Response to Step input');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.15: Impulse_and_Step_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.15 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Plotting the impulse and step responses\n",
+"clc;\n",
+"clear;\n",
+"syms s t R L;\n",
+"Y1=(1/s)-(1/(s+(R/L)));\n",
+"disp(Y1,'Laplace Transform Of differential Equation is:')\n",
+"y1=ilaplace(Y1,s,t);\n",
+"disp(y1,'The Step Response of the System is:');\n",
+"//Taking R/L=1;\n",
+"for k=0:10;\n",
+" y1(k+1)=1-exp(-k);\n",
+"end\n",
+"k=0:10;\n",
+"plot(k,y1);\n",
+"title('System Response to Step input');\n",
+"Y2=(1/(s+(R/L)));\n",
+"disp(Y2,'Laplace Transform Of differential Equation is:')\n",
+"y2=ilaplace(Y2,s,t);\n",
+"disp(y2,'The Impulse Response of the System is:');\n",
+"for k=0:10;\n",
+" y2(k+1)=exp(-k);\n",
+"end\n",
+"figure(1);\n",
+"k=0:10;\n",
+"plot(k,y2);\n",
+"title('System Response to impulse input');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.19: Convolution.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.19 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Convolution of two signals\n",
+"clc;\n",
+"clear;\n",
+"clear x y n;\n",
+"x=[2,-1,1,0,2];\n",
+"y=[1,0,-1,2];\n",
+"n=-1:3;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,x,-5);\n",
+"title('x(k)')\n",
+"xlabel('k')\n",
+"figure(1);\n",
+"n=0:3;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,y,-5);\n",
+"title('y(k)')\n",
+"xlabel('k')\n",
+"z=conv(x,y);\n",
+"figure(2);\n",
+"n=-1:6;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,z,-5);\n",
+"title('Convoluted signal z(t)')\n",
+"xlabel('t')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.1: Properties_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.1 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear;\n",
+"a0=2;\n",
+"a1=2;\n",
+"a2=4;\n",
+"x1=[1,3,5,7];\n",
+"x2=[2,4,6,8];\n",
+"for t=1:4\n",
+" y1(1,t)=a0+a1*x1(t)+a2*(x1(t))^2;\n",
+" y2(1,t)=a0+a1*x2(t)+a2*(x2(t))^2;\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp('y(n) does not depend on past inputs');\n",
+"disp('Hence the system is Static');\n",
+"disp(x,'The input to the system is:');\n",
+"for t=1:4\n",
+" q(1,t)=a0+a1*x(t)+a2*(x(t))^2;\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('Hence the system is not linear');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.22: Convolution.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.22 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Convolution of two signals\n",
+"clc;\n",
+"clear;\n",
+"clear x y n;\n",
+"for n=0:10;\n",
+" x(n+1)=(3/4)^n*u(n);\n",
+"end\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"n=0:10;\n",
+"plot2d3(n,x,-4);\n",
+"title('x(n)')\n",
+"xlabel('n')\n",
+"for n=0:10;\n",
+" y(n+1)=u(n);\n",
+"end\n",
+"figure(1);\n",
+"n=0:10;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,y,-4);\n",
+"title('y(k)')\n",
+"xlabel('k')\n",
+"z=conv(x,y);\n",
+"figure(2);\n",
+"n=0:20;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,z,-4);\n",
+"title('Convoluted signal w(t)');\n",
+"xlabel('t');\n",
+"disp(z(1),'z(0)',z(4),'z(3)',z(6),'z(5)',z(11),'z(10)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.23: Convolution.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.23 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Convolution of two signals\n",
+"clc;\n",
+"clear;\n",
+"clear x y n;\n",
+"for n=0:10;\n",
+" x(n+1)=(0.5)^n*u(n-2);\n",
+"end\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"n=0:10;\n",
+"plot2d3(n,x,-4);\n",
+"title('x(n)')\n",
+"xlabel('n')\n",
+"for n=0:10;\n",
+" y(n+1)=u(n);\n",
+"end\n",
+"figure(1);\n",
+"n=0:10;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,y,-4);\n",
+"title('y(k)')\n",
+"xlabel('k')\n",
+"z=conv(x,y);\n",
+"figure(2);\n",
+"n=0:20;\n",
+"c = gca();\n",
+"c.y_location = 'origin';\n",
+"c.x_location = 'origin';\n",
+"plot2d3(n,z,-4);\n",
+"title('Convoluted signal z(t)')\n",
+"xlabel('t')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24: Step_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.24 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Plotting the step response\n",
+"clc;\n",
+"clear;\n",
+"syms z n;\n",
+"y1=2*(1-0.5^n);\n",
+"disp(y1*'u(n)','The step Response of the System is:');\n",
+"for n=0:10;\n",
+" q(n+1)=2*(1-0.5^n);\n",
+"end\n",
+"n=0:10;\n",
+"plot(n,q);\n",
+"title('Step Response g(n)');\n",
+"xlabel('n-->');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.25: Step_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.25 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Plotting the impulse and step responses\n",
+"clc;\n",
+"clear;\n",
+"syms z a n;\n",
+"Y1=(2*z/(z-a));\n",
+"disp(Y1,'Z Transform Of differential Equation is:')\n",
+"y12=2*a^n;\n",
+"disp(y12,'The Unit Sample Response of the System is:');\n",
+"y2=2*(a^n-1)/(a-1);\n",
+"disp(y2,'The Step Response of the System is:');\n",
+"q=1;\n",
+"a=0.5;\n",
+"for k=0:0.1:5;\n",
+"y2(q)=2*((a^k-1)/(a-1));\n",
+"q=q+1;\n",
+"end\n",
+"k=0:0.1:5;\n",
+"plot(k,y2);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.33: Magnitude_and_Phase_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.33 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"//Plotting the magnitude and phase responses\n",
+"clc;\n",
+"clear;\n",
+"T=1;\n",
+"n=1;\n",
+"for w=0:0.1:20;\n",
+" hmag(n)=2*sin(w*T/2);\n",
+" n=n+1;\n",
+"end\n",
+"n=1;\n",
+"for w=0:0.1:20;\n",
+" hphase(n)=%pi/2-(w*T/2);\n",
+" n=n+1;\n",
+"end\n",
+"//Magnitude plot\n",
+"w=0:0.1:20;\n",
+"plot(w,hmag);\n",
+"title('Magnitude Plot');\n",
+"xlabel('w');\n",
+"ylabel('|H(e^jw)|');\n",
+"figure(1);\n",
+"//Phase Plot\n",
+"w=0:0.1:20;\n",
+"plot(w,hphase);\n",
+"title('Phase Plot');\n",
+"xlabel('w');\n",
+"ylabel('theta(wT)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.3: System_Properties.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.3 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(n)=x(n)-x(n-1);\n",
+"disp('y(n) depends upon past inputs also');\n",
+"disp('Output at n=2 depends upon value of x at n=1');\n",
+"disp('Hence the system is Dynamic');\n",
+"x1=[1,3,5,7,2];\n",
+"x2=[2,4,6,8,3];\n",
+"for n=2:5\n",
+" y1(1,n)=x1(n)-x1(n-1)\n",
+" y2(1,n)=x2(n)-x2(n-1)\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2\n",
+"disp(x,'The input to the system is:');\n",
+"for n=2:5\n",
+" q(1,n)=x(n)-x(n-1);\n",
+"end\n",
+"y=b1*y1+b2*y2;\n",
+"disp(q,'This input gives the output:');\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('Hence the system is linear');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.4: System_Properties.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.4 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(t)=x(2*t)\n",
+"disp('y(t) depends upon past inputs for t<0');\n",
+"disp('y(t) depends upon future inputs for t>0');\n",
+"disp('Hence the system is Dynamic');\n",
+"x1=[1,3,5,7,2,5,3,9];//Random Variable\n",
+"x2=[2,4,6,8,2,4,2,1];\n",
+"for t=1:4\n",
+" y1(1,t)=x1(2*t);\n",
+" y2(1,t)=x2(2*t);\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp(x,'The input to the system is:');\n",
+"for t=1:4\n",
+" q(1,t)=x(2*t);\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('Hence the system is linear');\n",
+"disp('For a delay (T) of 2 seconds');\n",
+"disp('At t=3 seconds:');\n",
+"t=3;\n",
+"a=x(1,2*t-2);\n",
+"b=y(1,t-2);\n",
+"c=x(1,2*t-4);\n",
+"disp(a,'x(2t-T):');\n",
+"disp(b,'is not equal to y(2t-T):');\n",
+"disp(c,'while x(2t-2*T):');\n",
+"disp('Hence the system is Time variant');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5: System_Properties.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.5 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(t)=x(2*n)\n",
+"disp('y(n) depends upon past inputs for n<0');\n",
+"disp('y(n) depends upon future inputs for n>0');\n",
+"disp('Hence the system is Dynamic');\n",
+"x1=[1,3,5,3,2,5,3,9];//random variable\n",
+"x2=[2,4,6,4,2,4,2,1];\n",
+"for n=1:4\n",
+" y1(1,n)=x1(2*n);\n",
+" y2(1,n)=x2(2*n);\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp(x,'The input to the system is:');\n",
+"for n=1:4\n",
+" q(1,n)=x(2*n);\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('Hence the system is linear');\n",
+"disp('For a delay (n0) of 2 seconds');\n",
+"disp('At n=3 seconds:');\n",
+"t=3;\n",
+"a=x(1,2*n-2);\n",
+"b=y(1,n-2);\n",
+"c=x(1,2*n-4);\n",
+"disp(a,'x(2n-n0):');\n",
+"disp(b,'is not equal to y(2n-n0):');\n",
+"disp(c,'while x(2n-2*n0):');\n",
+"disp('Hence the system is Time variant');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.6: System_Properties.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.6 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(n)=x(n)-x(n-1);\n",
+"x=[2,4,3,6,7]\n",
+"for n=2:5\n",
+" y(1,n)=x(n)-x(n-1);\n",
+"end\n",
+"disp(y,'This input gives the output:');\n",
+"disp('For a shift (n0) of 2 seconds');\n",
+"disp('At n=3 seconds:');\n",
+"n=5;\n",
+"b=y(n-2);\n",
+"a=x(n-2)-x(n-2-1);\n",
+"disp(a,'x(n-2):');\n",
+"disp(b,'is equal to y(n-2):');\n",
+"disp('Hence the system is Shift invariant/fixed');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.7: Properties_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.7 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(t)=n*x(n)\n",
+"disp('y(n) depends only upon present inputs');\n",
+"disp('(i) Hence the system is Dynamic');\n",
+"x1=[1,3,5,3,2,5,3,9];//random variable\n",
+"x2=[2,4,6,4,2,4,2,1];\n",
+"for n=1:4\n",
+" y1(1,n)=n*x1(n);\n",
+" y2(1,n)=n*x2(n);\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp(x,'The input to the system is:');\n",
+"for n=1:4\n",
+" q(1,n)=n*x(n);\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('(ii) Hence the system is linear');\n",
+"disp('For a delay (n0) of 2 seconds');\n",
+"disp('At n=3 seconds:');\n",
+"t=3;\n",
+"a=x(1,n-2);\n",
+"b=y(1,n-2);\n",
+"c=2*x(1,n-2);\n",
+"disp(a,'x(n-n0):');\n",
+"disp(b,'is not equal to y(n-n0):');\n",
+"disp(c,'while (n-n0)*x(n-n0):');\n",
+"disp('(iii) Hence the system is Time variant');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.8: Properties_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.8 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(t)=sum(x(n)),n-2<=n=<n+2\n",
+"x1=[1,3,5,3,0,0,0,0,0,0];//random variable\n",
+"x2=[2,4,6,4,0,0,0,0,0,0];\n",
+"for n=1:4\n",
+" y1(1,n)=x1(n)+x1(n+1)+x1(n+2)+x1(n+3)+x1(n+4);\n",
+" y2(1,n)=x2(n)+x2(n+1)+x2(n+2)+x2(n+3)+x2(n+4);\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp(x,'The input to the system is:');\n",
+"for n=1:4\n",
+" q(1,n)=x(n)+x(n+1)+x(n+2)+x(n+3)+x(n+4);\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('(i) Hence the system is linear');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.9: Properties_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Scilab Code for Example 7.9 of Signals and systems by\n",
+"//P.Ramakrishna Rao\n",
+"clc;\n",
+"clear x y1 y y2 q t n;\n",
+"clear;\n",
+"//y(t)=exp|x(n)|\n",
+"x1=[1,3,5,3];//random variable\n",
+"x2=[2,4,6,4];\n",
+"for n=1:4\n",
+" y1(1,n)=exp(abs(x1(n)));\n",
+" y2(1,n)=exp(abs(x2(n)));\n",
+"end\n",
+"b1=2;\n",
+"b2=3;\n",
+"x=b1*x1+b2*x2;\n",
+"disp(x,'The input to the system is:');\n",
+"for n=1:4\n",
+" q(1,n)=exp(abs(b1*(x1(n))+b2*(x2(n))));\n",
+"end\n",
+"disp(q,'This input gives the output:');\n",
+"y=b1*y1+b2*y2;\n",
+"disp(y,'For the system to be linear the output should be:');\n",
+"disp('(ii) Hence the system is not linear');\n",
+"disp('For a delay (n0) of 2 seconds');\n",
+"disp('At n=3 seconds:');\n",
+"n=4;\n",
+"a=exp(abs(x1(n-2)));\n",
+"b=y1(1,n-2);\n",
+"disp(a,'e^x(n-n0):');\n",
+"disp(b,'is equal to y(n-n0):');\n",
+"disp('(iii) Hence the system is Time invariant');"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}