{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 10: Stability" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.02_01: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s = poly(0, 's');\n", "p=poly([12],'s','coeff');\n", "q=poly([0 2 4 1],'s','coeff');\n", "G=p/q;\n", "H=poly([0.5],'s','coeff');\n", "//characteristic equation is 1+G(s)H(s)=0\n", "y=1+G*H\n", "r=numer(y)\n", "disp('=0',r,'characteristics equation is') " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.02_02: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s = poly(0, 's');\n", "p=poly([7],'s','coeff');\n", "q=poly([ 2 3 1],'s','coeff');\n", "G=p/q;\n", "H=poly([0 1],'s','coeff');\n", "//characteristic equation is 1+G(s)H(s)=0\n", "y=1+G*H\n", "r=numer(y)\n", "disp('=0',r,'characteristics equation is') " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.02_03: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s = poly(0, 's');\n", "G=syslin('c',2/(s^2+2*s))\n", "H=syslin('c',1/s);\n", "//characteristic equation is 1+G(s)H(s)=0\n", "y=1+G*H\n", "r=numer(y)\n", "disp('=0',r,'characteristics equation is') " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.03: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s=%s;\n", "m=s^3+5*s^2+10*s+3;\n", "r=coeff(m)\n", "n=length(r);\n", "routh=[r([4,2]);r([3,1])];\n", "routh=[routh;-det(routh)/routh(2,1),0];\n", "t=routh(2:3,1:2); //extracting the square sub block of routh matrix\n", "routh=[routh;-det(t)/t(2,1),0]\n", "c=0;\n", "for i=1:n\n", "if (routh(i,1)< 0)\n", "c=c+1;\n", "end \n", "end\n", "if(c>=1)\n", "printf('system is unstable')\n", "else ('system is stable')\n", "end\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.04: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s=%s;\n", "m=s^3+2*s^2+3*s+10;\n", "r=coeff(m)\n", "n=length(r);\n", "routh=[r([4,2]);r([3,1])];\n", "routh=[routh;-det(routh)/routh(2,1),0];\n", "t=routh(2:3,1:2); //extracting the square sub block of routh matrix\n", "routh=[routh;-det(t)/t(2,1),0]\n", "c=0;\n", "for i=1:n\n", "if (routh(i,1)<0)\n", "c=c+1;\n", "end \n", "end\n", "if(c>=1)\n", "printf('system is unstable')\n", "else ('system is stable')\n", "end\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.05_01: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2)\n", "s=%s;\n", "m=s^4+6*s^3+21*s^2+36*s+20\n", "r=coeff(m)\n", "n=length(r);\n", "routh=[r([5,3,1]);r([4,2]),0]\n", "routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0];\n", "disp(routh,'routh=')\n", "c=0;\n", "for i=1:n\n", "if (routh(i,1)<0)\n", "c=c+1;\n", "end \n", "end\n", "if(c>=1)\n", "printf('system is unstable')\n", "else ('system is stable')\n", "end\n", " \n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.05_02: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s=%s;\n", "m=s^5+6*s^4+3*s^3+2*s^2+s+1\n", "r=coeff(m)\n", "n=length(r)\n", "routh=[r([6,4,2]);r([5,3,1])]\n", "routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(routh(1:2,2:3))/routh(2,2),0]\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0]\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),-det(routh(3:4,2:3))/routh(4,2),0]\n", "routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0]\n", "c=0;\n", "for i=1:n\n", "if (routh(i,1)<0)\n", "c=c+1;\n", "end \n", "end\n", "if(c>=1)\n", "printf('system is unstable')\n", "else ('system is stable')\n", "end\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.06: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2)\n", "s=%s;\n", "m=s^5+2*s^4+4*s^3+8*s^2+3*s+1\n", "r=coeff(m); //Extracts the coefficient of the polynomial\n", "n=length(r); \n", "routh=[r([6,4,2]);r([5,3,1])]\n", "syms eps;\n", "routh=[routh;eps,-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),-det(routh(3:4,2:3))/routh(4,2),0];\n", "routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0];\n", "disp(routh,'routh=') \n", "//To check the stability\n", "routh(4,1)=8-limit(5/eps,eps,0); //Putting the value of eps=0 in routh(4,1)\n", "disp(routh(4,1),'routh(4,1)=')\n", "routh(5,1)= limit(routh(5,1),eps,0); //Putting the value of eps=0 in routh(5,1)\n", "disp(routh(5,1),'routh(5,1)=')\n", "routh\n", "printf('There are two sign changes of first column,hence the system is unstable \n')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.07: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s=%s;\n", "m=s^5+2*s^4+2*s^3+4*s^2+4*s+8\n", "routh=routh_t(m) //This Function generates the Routh table\n", "c=0;\n", "for i=1:n\n", "if (routh(i,1)<0)\n", "c=c+1;\n", " end \n", " end\n", " if(c>=1)\n", " printf('system is unstable')\n", " else ('system is stable')\n", " end\n", " \n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.08: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "s=%s;\n", "m=s^4+5*s^3+2*s^2+3*s+2\n", "r=coeff(m)\n", "n=length(r);\n", "routh=[r([5,3,1]);r([4,2]),0]\n", "routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0]\n", " c=0;\n", " for i=1:n\n", " if (routh(i,1)<0)\n", " c=c+1;\n", " end \n", " end\n", " if(c>=1)\n", " printf('system is unstable')\n", " else ('system is stable')\n", " end\n", " \n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.09: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "s=%s;\n", "m=s^5+s^4+3*s^3+3*s^2+4*s+8\n", "r=coeff(m); //Extracts the coefficient of the polynomial\n", "n=length(r); \n", "routh=[r([6,4,2]);r([5,3,1])]\n", "syms eps;\n", "routh=[routh;eps,-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),-det(routh(3:4,2:3))/routh(4,2),0];\n", "routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0];\n", "disp(routh,'routh=') \n", "//To check the stability\n", "routh(4,1)=limit(routh(4,1),eps,0); //Putting the value of eps=0 in routh(4,1)\n", "disp(routh(4,1),'routh(4,1)=')\n", "routh(5,1)= limit(routh(5,1),eps,0); //Putting the value of eps=0 in routh(5,1)\n", "disp(routh(5,1),'routh(5,1)=')\n", "routh\n", "printf('There are two sign changes of first column,hence the system is unstable \n')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.10: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "syms s k;\n", "m=s^4+4*s^3+7*s^2+6*s+k;\n", "cof_a_0 = coeffs(m,'s',0);\n", "cof_a_1 = coeffs(m,'s',1);\n", "cof_a_2 = coeffs(m,'s',2);\n", "cof_a_3 = coeffs(m,'s',3);\n", "cof_a_4 = coeffs(m,'s',4);\n", " \n", "r=[cof_a_0 cof_a_1 cof_a_2 cof_a_3 cof_a_4] \n", "\n", "n=length(r);\n", "routh=[r([5,3,1]);r([4,2]),0]\n", "routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0];\n", "disp(routh,'routh=')\n", "\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.11: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "syms s k;\n", "m=(24/100)*s^3+s^2+s+k;\n", "cof_a_0 = coeffs(m,'s',0);\n", "cof_a_1 = coeffs(m,'s',1);\n", "cof_a_2 = coeffs(m,'s',2);\n", "cof_a_3 = coeffs(m,'s',3);\n", "r=[cof_a_0 cof_a_1 cof_a_2 cof_a_3] \n", "n=length(r);\n", "routh=[r([4,2]);r([3,1])]\n", "routh=[routh;-det(routh)/routh(2,1),0]\n", "t=routh(2:3,1:2); //extracting the square sub block of routh matrix\n", "routh=[routh;-det(t)/routh(3,1),0]\n", "disp(routh,'routh=');\n", "routh(3,1)=0 //For marginaly stable system\n", "k=1/0.24;\n", "disp(k,'K(marginal)=')\n", "disp('=0',(s^2)+k,'auxillary equation')\n", "s=sqrt(-k);\n", "disp(s,'Frequency of oscillation(in rad/sec)=')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.12: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "syms p K s;\n", "m=s^3+(p*s^2)+(K+3)*s+(2*(K+1))\n", "cof_a_0 = coeffs(m,'s',0);\n", "cof_a_1 = coeffs(m,'s',1);\n", "cof_a_2 = coeffs(m,'s',2);\n", "cof_a_3 = coeffs(m,'s',3);\n", "r=[cof_a_0 cof_a_1 cof_a_2 cof_a_3] \n", "n=length(r);\n", "routh=[r([4,2]);r([3,1])];\n", "routh=[routh;-det(routh)/routh(2,1),0];\n", "t=routh(2:3,1:2); //extracting the square sub block of routh matrix\n", "routh=[routh;-det(t)/routh(3,1),0];\n", "disp(routh,'routh=')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.13: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "s=%s;\n", "m=2*s^4+(4*s^2)+1\n", "routh=routh_t(m) //Generates the Routh Table\n", "roots(m) //Gives the Roots of the Polynomial(m)\n", "disp(0,'the number of roots lying in the left half plane of s-plane=')\n", "disp(0,'the number of roots lying in the right half plane of s-plane=')\n", "disp(4,'the number of roots lying on the imaginary axis=')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.14: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "syms s k;\n", "m=s^4+6*s^3+10*s^2+8*s+k;\n", "cof_a_0 = coeffs(m,'s',0);\n", "cof_a_1 = coeffs(m,'s',1);\n", "cof_a_2 = coeffs(m,'s',2);\n", "cof_a_3 = coeffs(m,'s',3);\n", "cof_a_4 = coeffs(m,'s',4);\n", "r=[cof_a_0 cof_a_1 cof_a_2 cof_a_3 cof_a_4] \n", "n=length(r);\n", "routh=[r([5,3,1]);r([4,2]),0]\n", "routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0];\n", "disp(routh,'routh=')\n", "\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.15: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2);\n", "syms s T;\n", "m=s^2+(2-T)*s+1\n", "cof_a_0 = coeffs(m,'s',0);\n", "cof_a_1 = coeffs(m,'s',1);\n", "cof_a_2 = coeffs(m,'s',2);\n", "r=[cof_a_0 cof_a_1 cof_a_2] \n", "n=length(r);\n", "routh=[r([3,1]);r(2),0];\n", "routh=[routh;-det(routh)/routh(2,1),0];\n", "disp(routh,'routh=')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 10.16: equatio.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//equation//\n", "ieee(2)\n", "s=%s;\n", "m=s^6+2*s^5+7*s^4+10*s^3+14*s^2+8*s+8\n", "routh=routh_t(m);\n", "disp(routh,'routh=')\n", " c=0;\n", " for i=1:n\n", " if (routh(i,1)<0)\n", " c=c+1;\n", " end \n", " end\n", " if(c>=1)\n", " printf('system is unstable')\n", " else ('system is stable')\n", " end\n", " \n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 11.08: value.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//value//\n", "s=%s;\n", "H=syslin('c',(s+2)/((s+1)*s*(s+4)));\n", "evans(H,100)\n", "printf('From the graph we observed that, \n a)The no of loci ending at inf is 2 \n b)Three loci will start from s= 0,-1 & -4,\n c)One loci will end at -2 & remaining two will end at inf') \n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 6.0: coefficient.sci" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//coefficient//\n", "ieee(2);\n", "s=%s;\n", "m=s^5+2*s^4+4*s^3+8*s^2+3*s+1\n", "r=coeff(m); //Extracts the coefficient of the polynomial\n", "n=length(r); \n", "routh=[r([6,4,2]);r([5,3,1])]\n", "syms eps;\n", "routh=[routh;eps,-det(routh(1:2,2:3))/routh(2,2),0];\n", "routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(routh(2:3,2:3))/routh(3,2),0];\n", "routh=[routh;-det(routh(3:4,1:2))/routh(4,1),-det(routh(3:4,2:3))/routh(4,2),0];\n", "routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0];\n", "disp(routh,'routh=') \n", "//To check the stability\n", "routh(4,1)=8-limit(5/eps,eps,0); //Putting the value of eps=0 in routh(4,1)\n", "disp(routh(4,1),'routh(4,1)=')\n", "routh(5,1)= limit(routh(5,1),eps,0); //Putting the value of eps=0 in routh(5,1)\n", "disp(routh(5,1),'routh(5,1)=')\n", "routh\n", "printf('There are two sign changes of first column,hence the system is unstable \n')" ] } ], "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 }