summaryrefslogtreecommitdiff
path: root/Linear_Control_Systems_by_B_S_Manke
diff options
context:
space:
mode:
authorPrashant S2020-04-14 10:25:32 +0530
committerGitHub2020-04-14 10:25:32 +0530
commit06b09e7d29d252fb2f5a056eeb8bd1264ff6a333 (patch)
tree2b1df110e24ff0174830d7f825f43ff1c134d1af /Linear_Control_Systems_by_B_S_Manke
parentabb52650288b08a680335531742a7126ad0fb846 (diff)
parent476705d693c7122d34f9b049fa79b935405c9b49 (diff)
downloadall-scilab-tbc-books-ipynb-master.tar.gz
all-scilab-tbc-books-ipynb-master.tar.bz2
all-scilab-tbc-books-ipynb-master.zip
Merge pull request #1 from prashantsinalkar/masterHEADmaster
Initial commit
Diffstat (limited to 'Linear_Control_Systems_by_B_S_Manke')
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/1-INTRODUCTION.ipynb467
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/11-SOLUTION_OF_PROBLEMS_USING_COMPUTER.ipynb1424
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/12-CLASSIFIED_SOLVED_EXAMPLES.ipynb1667
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/2-TRANSFER_FUNCTIONS.ipynb96
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/3-BLOCK_DIAGRAMS.ipynb601
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/4-SIGNAL_FLOW_GRAPHS.ipynb474
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/5-MODELLING_A_CONTROL_SYSTEM.ipynb421
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/6-TIME_RESPONSE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb1060
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/7-STABILITY_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb1520
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/8-COMPENSATION_OF_CONTROL_SYSTEMS.ipynb210
-rw-r--r--Linear_Control_Systems_by_B_S_Manke/9-INTRODUCTION_TO_STATE_SPACE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb836
11 files changed, 8776 insertions, 0 deletions
diff --git a/Linear_Control_Systems_by_B_S_Manke/1-INTRODUCTION.ipynb b/Linear_Control_Systems_by_B_S_Manke/1-INTRODUCTION.ipynb
new file mode 100644
index 0000000..737b769
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/1-INTRODUCTION.ipynb
@@ -0,0 +1,467 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 1: INTRODUCTION"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_10: final_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:final_value\n",
+"// example 1.6.10\n",
+"//page 13\n",
+"syms t s;\n",
+"F=4/(s^2+2*s)\n",
+"x=s*F\n",
+"x=simple(x)\n",
+"z=limit(x,s,0);//final value theorem\n",
+"z=dbl(z);\n",
+"disp(z,'f(0+)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_iii: inverse_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:inverse_laplace_transform\n",
+"// example 1.6.1.(iii)\n",
+"//page 8\n",
+"// F(s)=1/(s^2+4s+8)\n",
+"s =%s ;\n",
+"syms t ;\n",
+"disp(1/(s^2+4*s+8),'F(s)=')\n",
+"f=ilaplace(1/(s^2+4*s+8),s,t)\n",
+"disp (f,' f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_ii: inverse_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:inverse_laplace_transform\n",
+"// example 1.6.1.(ii)\n",
+"//page 7\n",
+"// F(s)=s+6/(s(s^2+4s+3))\n",
+"s =%s ;\n",
+"syms t ;\n",
+"[A]= pfss((s+6)/(s*(s^2+4*s+3))) // partial fraction of F(s)\n",
+"A(1)=2/s;\n",
+"F1 = ilaplace (A(1),s,t)\n",
+"F2 = ilaplace (A(2),s,t)\n",
+"F3 = ilaplace (A(3),s,t)\n",
+"F=F1+F2+F3;\n",
+"disp (F,' f (t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_i: inverse_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:inverse_laplace_transform\n",
+"// example 1.6.1.(i)\n",
+"//page 7\n",
+"// F(s)=1/(s*(s+1))\n",
+"s =%s ;\n",
+"syms t ;\n",
+"[A]=pfss(1/((s)*(s+1))) // partial fraction of F(s)\n",
+"F1 = ilaplace (A(1),s,t)\n",
+"F2 = ilaplace (A(2),s,t)\n",
+"F=F1+F2;\n",
+"disp (F,' f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_iv: inverse_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:inverse_laplace_transform\n",
+"// example 1.6.1.(iv)\n",
+"//page 8\n",
+"// F(s)=s+2/(s^2+4s+6)\n",
+"s =%s ;\n",
+"syms t ;\n",
+"disp((s+2)/(s^2+4*s+6),'F(s)=')\n",
+"F=ilaplace((s+2)/(s^2+4*s+6),s,t)\n",
+"disp (F,' f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_v: inverse_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:inverse_laplace_transform\n",
+"// example 1.6.1.(v)\n",
+"//page 8\n",
+"// F(s)=5/(s(s^2+4s+5))\n",
+"s =%s ;\n",
+"syms t ;\n",
+"[A]= pfss (5/(s*(s^2+4*s+5))) // partial fraction of F(s)\n",
+"F1= ilaplace (A(1),s,t)\n",
+"F2= ilaplace (A(2),s,t)\n",
+"F=F1+F2;\n",
+"disp (F,'f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_1_vi: program_laplace_transform.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:program_laplace_transform\n",
+"//example 1.6.1.(v)\n",
+"//page 9\n",
+"//this problem is solved in two parts because in this problem pfss function donot work.So, First we find partial fraction using method as we do in maths and then secondly we find inverse laplace transform as usual.\n",
+"// partial fraction \n",
+"s=%s\n",
+"syms t;\n",
+"num=(s^2+2*s+3);\n",
+"den=(s+2)^3;\n",
+"g=syslin('c',num/den);\n",
+"rd=roots(den);\n",
+"[n d k]=factors(g)\n",
+"a(3)=horner(g*d(1)^3,rd(1))\n",
+"a(2)=horner(derivat(g*d(1)^3),rd(1))\n",
+"a(1)=horner(derivat(derivat(g*d(1)^3)),rd(1))\n",
+"//inverse laplace\n",
+"// partial fraction will be: a(1)/(s+1)+a(2)/((s+2)^2)+a(3)/((s+2)^3)\n",
+"F1 = ilaplace (1/d(1),s,t)\n",
+"F2 = ilaplace (-2/(d(1)^2),s,t)\n",
+"F3 = ilaplace (2*1.5/(d(1)^3),s,t)\n",
+"F=F1+F2+F3\n",
+"disp (F,' f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_2: solution_of_differential_equation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:solution_of_differential equation\n",
+"// example 1.6.2\n",
+"//page 9\n",
+"//after taking laplace transform and applying given condition, we get :\n",
+"//X(s)=2s+5/(s(s+4))\n",
+"s=%s;\n",
+"syms t\n",
+"[A]=pfss((2*s+5)/(s*(s+4)))\n",
+"A(1)=1.25/s\n",
+"F1 =ilaplace(A(1),s,t)\n",
+"F2 = ilaplace(A(2),s,t)\n",
+"f=F1+F2;\n",
+"disp (f,'f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_3: solution_of_differential_equation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:solution_of_differential_equation\n",
+"// example 1.6.3\n",
+"//page 10\n",
+"//after taking laplace transform and applying given condition, we get :\n",
+"//X(s)=1/(s^2+2s+2)\n",
+"s=%s;\n",
+"syms t\n",
+"f = ilaplace(1/(s^2+2*s+2),s,t);\n",
+"disp (f,'f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_4: solution_of_differential_equation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:solution_of_differential_equation\n",
+"// example 1.6.4\n",
+"//page 10\n",
+"//after taking laplace transform and applying given condition, we get :\n",
+"//Y(s)=(6*s+6)/((s-1)*(s+2)*(s+3))\n",
+"s=%s;\n",
+"syms t\n",
+"[A]=pfss((6*s+6)/((s-1)*(s+2)*(s+3)))\n",
+"F1 = ilaplace(A(1),s,t)\n",
+"F2 = ilaplace(A(2),s,t)\n",
+"F3 = ilaplace(A(3),s,t)\n",
+"F=F1+F2+F3;\n",
+"disp (F,'f(t)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_5: initial_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:initial_value\n",
+"// example 1.6.5\n",
+"//page 11\n",
+"//I(s)=(C*s/(RCs+1))*E(s)\n",
+"//given: E(s)=100/s,R=2 megaohm ,C=1 uF\n",
+"// so, I(s)=(((1*10^-6)*s)/(2*s+1))*(100/s)\n",
+"syms t\n",
+"p=poly([0 10^-6],'s','coeff');\n",
+"q=poly([1 2],'s','coeff');\n",
+"r=poly([0 1],'s','coeff');\n",
+"F1=p/q;\n",
+"F2=1/r;\n",
+"F=F1*F2\n",
+"f=ilaplace(F,s,t);\n",
+"z=limit(f,t,0);//initial value theorem\n",
+"z=dbl(z);\n",
+"disp(z,'i(0+)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_7: final_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:final_value\n",
+"// example 1.6.7\n",
+"//page 12\n",
+"//X(s)=100/(s*(s^2+2*s+50))\n",
+"p=poly([100],'s','coeff');\n",
+"q=poly([0 50 2 1],'s','coeff');\n",
+"F=p/q;\n",
+"syms s\n",
+"x=s*F;\n",
+"y=limit(x,s,0);//final value theorem\n",
+"y=dbl(y)\n",
+"disp(y,'x(inf)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_8: steady_state_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:steady_state_value\n",
+"// example 1.6.7\n",
+"//page 12\n",
+"//X(s)=s/(s^2*(s^2+6*s+25))\n",
+"p=poly([0 1],'s','coeff');\n",
+"q=poly([0 0 25 6 1],'s','coeff');\n",
+"F=p/q;\n",
+"syms s\n",
+"x=s*F;\n",
+"y=limit(x,s,0);//final value theorem\n",
+"y=dbl(y)\n",
+"disp(y,'x(inf)=')//result"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.6_9: initial_values.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:initial_values\n",
+"// example 1.6.7\n",
+"//page 13\n",
+"//F(s)=(4*s+1)/(s^3+2*s)\n",
+"s=%s;\n",
+"syms t;\n",
+"F=(4*s+1)/(s^3+2*s)\n",
+"f = ilaplace (F,s,t);\n",
+"y=limit(f,t,0);//initial value theorem\n",
+"y=dbl(y);\n",
+"disp(y,'f(0+)=')\n",
+"// since F'(s)=sF(s)-f(0+) where L(f'(t))=F'(s)=F1\n",
+"F1=(4*s+1)/(s^2+2)\n",
+"f1= ilaplace(F1,s,t);\n",
+"y1=limit(f1,t,0);//initial value theorem\n",
+"y1=dbl(y1);\n",
+"disp(y1,'f_prime(0+)=')\n",
+"// since F''(s)=(s^2)*F(s)-s*f(0+)-f'(0+) where L(f''(t))=F''(s)=F2\n",
+"F2=(s-8)/(s^2+2)\n",
+"f2= ilaplace(F2,s,t);\n",
+"y2=limit(f2,t,0);//initial value theorem\n",
+"y2=dbl(y2);\n",
+"disp(y2,'f_doubleprime(0+)=')"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/11-SOLUTION_OF_PROBLEMS_USING_COMPUTER.ipynb b/Linear_Control_Systems_by_B_S_Manke/11-SOLUTION_OF_PROBLEMS_USING_COMPUTER.ipynb
new file mode 100644
index 0000000..38b6d44
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/11-SOLUTION_OF_PROBLEMS_USING_COMPUTER.ipynb
@@ -0,0 +1,1424 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 11: SOLUTION OF PROBLEMS USING COMPUTER"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.10_a: calculate_tr_Tp_Mp.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_tr,Tp,Mp\n",
+"//example 11_10_a\n",
+"//page 478\n",
+"s=%s;\n",
+"G=16/(s^2+1.6*s)\n",
+"H=1;\n",
+"CL=G/.H\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"b=denom(CL)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"tr=(%pi-atan(sqrt(1-zeta^2)/zeta))/(Wn*sqrt(1-zeta^2))//rise time\n",
+"Tp=%pi/Wd//peak time\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'max. peak overshoot=')\n",
+"disp(tr,'rise time=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.10_b: calculate_Td_tr_Tp_Mp.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_Td,tr,Tp,Mp\n",
+"//example 11_10_b\n",
+"//page 478\n",
+"s=%s;\n",
+"syms Td\n",
+"G=16/(s^2+1.6*s)\n",
+"G1=1+s*Td\n",
+"H=1;\n",
+"a=G*G1\n",
+"CL=a/.H\n",
+"CL=simple(CL)\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"zeta=0.8//given\n",
+"//since zeta=0.8 so 2*zeta*Wn=1.6+16*Td\n",
+"Wn=sqrt(16)\n",
+"//so on solving \n",
+"Td=0.3\n",
+"//so transfer function takes the form:\n",
+"CL1=(16+4.8*s)/(s^2+6.4*s+6)\n",
+"disp(CL1,'C(s)/R(s)=');\n",
+"Wn1=sqrt(16)\n",
+"//2*zeta1*Wn1=6.4\n",
+"zeta1=6.4/(2*Wn1)//damping ratio\n",
+"Wd=Wn1*sqrt(1-zeta1^2)//damped frequency\n",
+"Mp=(exp(-(zeta1*%pi)/sqrt(1-zeta1^2)))*100//max. overshoot\n",
+"tr=(%pi-atan(sqrt(1-zeta1^2)/zeta1))/(Wn1*sqrt(1-zeta1^2))//rise time\n",
+"Tp=%pi/Wd//peak time\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'max. peak overshoot=')\n",
+"disp(tr,'rise time=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.11: expression_for_unit_step_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:expression_for_unit_step_response\n",
+"// example 11_11\n",
+"//page 481\n",
+"syms G1 G2 G3 H1 t;\n",
+"s=%s;\n",
+"G1=s+1;\n",
+"G2=1/(s+2);\n",
+"H2=1/(s*(s+1));\n",
+"H1=1/(s+2);\n",
+"a=G1/(1+G1*H1);\n",
+"b=a/(1+a*H2)\n",
+"y=b*G2;\n",
+"disp(y,'C(s)/R(s)=')\n",
+"//for unit step response R(s)=1/s;\n",
+"C=y*(1/s)\n",
+"c=ilaplace(C,s,t)\n",
+"disp(c,'expression_for_unit_step_response_is=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.12: unit_step_and_impulse_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:unit_step_and_impulse_response\n",
+"//example 11_12\n",
+"//page 482\n",
+"s=%s;\n",
+"syms t;\n",
+"G=(4*s+1)/(4*s^2)\n",
+"H=1;\n",
+"CL=G/.H\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"y=ilaplace(CL,s,t);\n",
+"disp(y,'unit impulse response,c(t)=');\n",
+"//for unit step response R(s)=1/s;\n",
+"C=CL*(1/s)\n",
+"c=ilaplace(C,s,t)\n",
+"disp(c,'expression_for_unit_step_response_is=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.13: determine_transfer_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_transfer_function\n",
+"//example 11_13\n",
+"//page 483\n",
+"syms t;\n",
+"f=exp(-t)*(1-cos(2*t))\n",
+"F=laplace(f,t,s);\n",
+"disp(F,'F(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.14: determine_Wn_Wd_Tp_zeta_and_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,Wd,Tp,zeta_and_steady_state_error\n",
+"//example 11_14\n",
+"//page 484\n",
+"s=%s;\n",
+"syms t;\n",
+"G=20/((s+5)*(s+1))\n",
+"H=1;\n",
+"CL=G/.H\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"b=denom(CL)\n",
+"disp(0,b,'=','the char. eq is:',)\n",
+"Wn=sqrt(25)//natural_frequency\n",
+"//2*zeta*Wn=6\n",
+"zeta=6/(2*Wn);//damping ratio\n",
+"d=zeta*Wn;//damping_factor\n",
+"z=sqrt(1-zeta^2);\n",
+"Wd=Wn*z;//damped_frequency_of_oscillation\n",
+"Mp=exp((-zeta*%pi)/z)*100;//%_max.peak_overshoot\n",
+"Tp=%pi/Wd//peak time\n",
+"tfirst=(2*%pi)/Wd //time for first under shoot\n",
+"period=(2*%pi)/Wd //period of oscillation\n",
+"ts=4/(zeta*Wn)//settling time\n",
+"N=(Wd/(2*%pi))*ts//no. of oscillations completed before reaching steady state\n",
+"disp(Wn,'natural frequency=');\n",
+"disp(zeta,'damping ratio=');\n",
+"disp(Wd,'damped frequency of oscillation=');\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'%_max.peak overshoot=');\n",
+"disp(tfirst,'time for first under shoot=');\n",
+"disp(period,'period of oscillation=');\n",
+"disp(N,'no. of oscillations completed before reaching steady state=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.15: determine_Wn_Wd_zeta_and_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,Wd,zeta_and_steady_state_error\n",
+"//example 11_15\n",
+"//page 484\n",
+"s=%s;\n",
+"G=sym('25/(s*(s+5))');\n",
+"G=simple(G);\n",
+"H=1;\n",
+"CL=G/.H;\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"printf('the char. eq is:')\n",
+"disp('s^2+5*s+25')\n",
+"Wn=sqrt(25)//natural_frequency\n",
+"//2*zeta*Wn=5\n",
+"zeta=5/(2*Wn);//damping ratio\n",
+"d=zeta*Wn;//damping_factor\n",
+"z=sqrt(1-zeta^2);\n",
+"Wd=Wn*z;//damped_frequency_of_oscillation\n",
+"Mp=exp((-zeta*%pi)/z)*100;//%_max.peak_overshoot\n",
+"//steady state error for unit ramp input is:Ess= (2*zeta/Wn)\n",
+"Ess=(2*zeta/Wn);//steady state error\n",
+"disp('part(a):')\n",
+"disp(Wn,'natural_frequency=');\n",
+"disp(zeta,'damping ratio=');\n",
+"disp(Wd,'damped_frequency_of_oscillation=');\n",
+"disp(Mp,'%_max.peak_overshoot=');\n",
+"disp(Ess,'steady state error=');\n",
+"//if damping ratio is increased from 0.5 to 0.75 by incorporating tachometer feedback\n",
+"zeta=0.75;\n",
+"H1=sym('s*Kt')//tachometer_feedback\n",
+"CL1=G/(1+G*H1);\n",
+"CL1=simple(CL1);\n",
+"CL2=CL1/(1+H*CL1);\n",
+"CL2=simple(CL2);\n",
+"disp(CL2,'C(s)/R(s)=');\n",
+"Wn=sqrt(25);\n",
+"//2*zeta*Wn=25*Kt+5;\n",
+"Kt=(2*zeta*Wn-5)/25;//tachometer_gain\n",
+"Mp1=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"disp('After applying tachometer feedback:')\n",
+"disp(Kt,'tachometer_gain=');\n",
+"disp(Mp1,'%_peak_overshoot=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.16: determine_Kp_Kv_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Kp_Kv_Ka\n",
+"//example 11_16\n",
+"//page 485\n",
+"s=%s;\n",
+"syms t;\n",
+"num=10\n",
+"den=sym('s^2+6*s+10');\n",
+"GH=num/den;\n",
+"GH=simple(GH);\n",
+"disp(GH,'G(s)H(s)=');\n",
+"Kp=limit(GH,s,0);//static positional error coefficient\n",
+"disp(Kp,'static positional error coefficient=');\n",
+"Kv=limit(s*GH,s,0);//static velocity error coefficient\n",
+"disp(Kv,'static velocity error coefficient=');\n",
+"Ka=limit(s^2*GH,s,0);//static acceleration error coefficient\n",
+"disp(Ka,'static acceleration error coefficient=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.17: determine_Kp_Kv_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Kp_Kv_Ka\n",
+"//example 11_16\n",
+"//page 485\n",
+"s=%s;\n",
+"syms t;\n",
+"num=sym('100*(s+2)*(s+40)');\n",
+"den=sym('(s^3*(s^2+4*s+200))');\n",
+"GH=num/den;\n",
+"GH=simple(GH);\n",
+"disp(GH,'G(s)H(s)=');\n",
+"Kp=limit(GH,s,0);//static positional error coefficient\n",
+"disp(Kp,'static positional error coefficient=');\n",
+"Kv=limit(s*GH,s,0);//static velocity error coefficient\n",
+"disp(Kv,'static velocity error coefficient=');\n",
+"Ka=limit(s^2*GH,s,0);//static acceleration error coefficient\n",
+"disp(Ka,'static acceleration error coefficient=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.18: determine_Kp_Kv_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Kp_Kv_Ka\n",
+"//example 11_18\n",
+"//page 488\n",
+"s=%s;\n",
+"syms t;\n",
+"num=sym('2*(s^2+3*s+20)');\n",
+"den=sym('s*(s+2)*(s^2+4*s+10)');\n",
+"GH=num/den;\n",
+"GH=simple(GH);\n",
+"disp(GH,'G(s)H(s)=');\n",
+"input1=5;\n",
+"Kp=limit(GH,s,0);//static positional error coefficient\n",
+"Ess=5*(1/(1+Kp));//steady state error\n",
+"e=(1/(%inf+1));\n",
+"e=0;\n",
+"Ess=e;\n",
+"disp(Kp,'static positional error coefficient=');\n",
+"disp(Ess,'steady state error=');\n",
+"input2=4*t;\n",
+"Kv=limit(s*GH,s,0);//static velocity error coefficient\n",
+"Ess=(1/Kv)*4;//steady state error\n",
+"disp(Kv,'static velocity error coefficient=');\n",
+"disp(Ess,'steady state error=');\n",
+"input3=(4*t^2)/2;\n",
+"Ka=limit(s^2*GH,s,0);//static acceleration error coefficient\n",
+"Ess=(1/Ka)*4;//steady state error\n",
+"disp(Ka,'static acceleration error coefficient=');\n",
+"disp('steady state error=');\n",
+"disp('infinity')\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.19: determine_transfer_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_transfer_function\n",
+"//example 11_19\n",
+"//page 489\n",
+"syms t;\n",
+"s=%s;\n",
+"c=0.5+(1.25*exp(-t))-(1.75*exp(-12*t));\n",
+"C=laplace(c,t,s);\n",
+"disp(C,'C(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.1: pole_zero_Plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:pole_zero_plot\n",
+"// example 11_1\n",
+"//page 468\n",
+"//transfer function:G(s)=((8*(s+3)*(s+4))/(s*(s+2)*(s^2+2*s+2)))\n",
+"s=%s;\n",
+"G=syslin('c',((8*(s+3)*(s+4))/(s*(s+2)*(s^2+2*s+2))));\n",
+"disp(G,'G(s)=');\n",
+"x=plzr(G)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.21_a: roots_of_characterstics_equatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:roots_of_characterstics_equation\n",
+"//example 11_21_a\n",
+"//page 491\n",
+"s=%s;\n",
+"num=210\n",
+"den=sym('s*(s+2)*(s^2+12*s+6)');\n",
+"G=num/den;\n",
+"G=simple(G);\n",
+"H=1;\n",
+"n1=poly([210],'s','coeff');\n",
+"d1=poly([210 192 390 44 1],'s','coeff');\n",
+"CL=syslin('c',n1,d1)\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"b=denom(CL)\n",
+"disp(0,'=',b,'the char. eq is:',)\n",
+"r=roots(b);\n",
+"disp(r,'roots of char. eq. are=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.21_b: bode_plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:bode_plot\n",
+"//example 11_21_b\n",
+"//page 491\n",
+"s=%s;\n",
+"num=210\n",
+"den=(s*(s+2)*(s^2+12*s+6));\n",
+"g=num/den;\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"gm=g_margin(G)\n",
+"pm=p_margin(G)\n",
+"disp(gm,'gain_margin=');\n",
+"disp(pm,'phase_margin=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.22: gain_margin_and_phase_margin.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:gain_margin_and_phase_margin\n",
+"//example 11_22\n",
+"//page 493\n",
+"s=%s;\n",
+"g=((2*(s+0.25))/(s^2*(s+1)*(s+0.5)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.1; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"show_margins(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq=');\n",
+"show_margins(G);\n",
+"disp('since gain and phase margin are both negative so system is unstable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.24: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 11_24\n",
+"//page 496\n",
+"clf;\n",
+"s=%s;\n",
+"s1=-s;\n",
+"g=50/((s+1)*(s+2));\n",
+"g1=50/((s1+1)*(s1+2));\n",
+"GH=syslin('c',g)\n",
+"GH1=syslin('c',g1)\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-5 30 -20 20]);\n",
+"xtitle('Nyquist plot of 50/((s+1)*(s+2))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is not encircled by Nyquist plot ,so N=0 and P=0(given)')\n",
+"N=0;//no. of encirclement of -1+%i0 by G(s)H(s) plot\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.25: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 11_25\n",
+"//page 497\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"g=(2.2/(s*(s+1)*(s^2+2*s+2)))\n",
+"g1=(2.2/(s1*(s1+1)*(s1^2+2*s1+2)))\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-2.5 0.2 -75 75]);\n",
+"disp('as the nyquist plot passes through the point -1+%i*0, so system is marginally stable and output represents sustained oscillations.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.26_ii: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 11_26_ii\n",
+"//page 497\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=4')\n",
+"g=(4*(s-1))/((s+2)*(s+3));\n",
+"g1=(4*(s1-1))/((s1+2)*(s1+3));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-1 1 -1 1]);\n",
+"xtitle('Nyquist plot of (2.5*(s+1))/((s+0.5)*(s-2))')\n",
+"disp('since the point(-1+%i0) is encircled anticlockwise by Nyquist plot ,so N=1 and P=1(given)')\n",
+"N=0;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.26_i: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 11_26_i\n",
+"//page 497\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=10')\n",
+"g=(10*(s-1))/((s+2)*(s+3));\n",
+"g1=(10*(s1-1))/((s1+2)*(s1+3));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-2 2 -2.5 2.5]);\n",
+"xtitle('Nyquist plot of (10*(s-1))/((s+2)*(s+3));')\n",
+"disp('since the point(-1+%i0) is encircled clockwise by Nyquist plot ,so N=-1 and P=1(given)')\n",
+"N=-1;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=1,there is one roots of closed loop characterstics eq having positive real part, hence system is unstable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.27: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 11_27\n",
+"//page 499\n",
+"s=%s;\n",
+"clf();\n",
+"g=((s^2+4)/(s*(s+1)));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.28: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 11_28\n",
+"//page 501\n",
+"s=%s;\n",
+"clf();\n",
+"g=1/(s*(s+2)*(s^2+2*s+2));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.29: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 11_29\n",
+"//page 502\n",
+"s=%s;\n",
+"g=1/(s*(s+1)*(s+3));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.2: transfer_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 11_2\n",
+"//page 469\n",
+"syms G1 G2 G3 H1;\n",
+"s=%s;\n",
+"G1=4/(s*(s+4));\n",
+"G2=s+1.2;\n",
+"G3=s+0.8;\n",
+"H1=1;\n",
+"H2=(G2+G3);\n",
+"a=G1/.H1;\n",
+"y=a/(1+a*H2)\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.30: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 11_30\n",
+"//page 503\n",
+"s=%s;\n",
+"g=1/(s*(s+4)*(s^2+4*s+13));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.31: design_lead_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:design_lead_compensator\n",
+"//example 11_31\n",
+"//page 339\n",
+"s=%s;\n",
+"clf();\n",
+"syms K;\n",
+"g=(K/(s*(1+0.2*s)));\n",
+"Kv=limit(s*g,s,0);//static velocity error coefficient\n",
+"//since Kv=10\n",
+"K=10;\n",
+"g=(10/(s*(1+0.2*s)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq_or_gain_cross_over_frequency=');\n",
+"disp('since P.M is less than desired value so we need phase lead network ')\n",
+"disp('selecting zero of lead compensating network at w=5.5rad/sec and pole at w=13.8rad/sec and applying gain to account attenuatin factor .')\n",
+"gc=(1+0.18*s)/(1+0.072*s)\n",
+"Gc=syslin('c',gc)\n",
+"disp(Gc,'transfer function of lead compensator=');\n",
+"G1=G*Gc\n",
+"disp(G1,'overall transfer function=');\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"figure();\n",
+"bode(G1, fmin, fmax);\n",
+"show_margins(G1)\n",
+"[gm,freqGM]=g_margin(G1);\n",
+"[pm,freqPM]=p_margin(G1);\n",
+"disp(pm,'phase_margin_of_compensated_system=');\n",
+"disp((freqPM*2*%pi),'gain_cross_over_frequency=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.32: nicholas_chart.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:nicholas_chart\n",
+"//example 11_32\n",
+"//page 507\n",
+"s=%s;\n",
+"num=20;\n",
+"den=(s*(s+2)*(s+5))\n",
+"g=num/den\n",
+"G=syslin('c',g)\n",
+"fmin=0.01\n",
+"fmax=100\n",
+"black(G,fmin,fmax)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.33: obtain_state_matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 11_33\n",
+"//page 509\n",
+"s=%s;\n",
+"g=(s+2)/((s+1)*(s+3));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.34: obtain_state_matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 11_34\n",
+"//page 509\n",
+"s=%s;\n",
+"g=(s^2+s+2)/(s^3+9*s^2+26*s+24);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.35: obtain_state_matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 11_35\n",
+"//page 510\n",
+"s=%s;\n",
+"g=1/(s^2+2*s+5);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.36: state_transition_matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:state_transition_matrix\n",
+"//example 11_36\n",
+"//page 511\n",
+"s=%s;\n",
+"syms t\n",
+"A=[1 4;-2 -5]\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"//for calculating state transistion matrix\n",
+"ip=[0 0;0 0]\n",
+"i=1;j=1;\n",
+"for i=1:2\n",
+" for j=1:2\n",
+" ip(i,j)=ilaplace(r(i,j),s,t);\n",
+" j=j+1;\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"disp(ip,'state transistion matrix,ip(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.37: check_for_contrallability_of_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_of_system\n",
+"//example 11_37\n",
+"//page 512\n",
+"A=[1 1;0 -1]\n",
+"B=[1;0]\n",
+"P=cont_mat(A,B);\n",
+"disp(P,'Controllability Matrix=');\n",
+"d=determ(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.38: determine_transfer_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_function\n",
+"//example 11_38\n",
+"//page 513\n",
+"s=%s\n",
+"A=[-5 1;-6 0]\n",
+"B=[1;2]\n",
+"C=[2 1]\n",
+"D=0;\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B+D//transfer matrix\n",
+"disp(G,'transfer matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.39: determine_transfer_matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_matrix\n",
+"//example 11_39\n",
+"//page 513\n",
+"s=%s\n",
+"A=[0 1;-6 -5]\n",
+"B=[0;1]\n",
+"C=[2 1]\n",
+"D=0;\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B+D//transfer matrix\n",
+"disp(G,'transfer matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.3: transfer_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 11_3\n",
+"//page 470\n",
+"syms G1 G2 G3 H1;\n",
+"s=%s;\n",
+"G1=4;\n",
+"G2=s\n",
+"G3=1/(s*(s+2));\n",
+"H1=0.5;\n",
+"H2=1;\n",
+"a=(G1+G2);\n",
+"b=(a*G3);\n",
+"c=b/.H1;\n",
+"y=c/(1+c*H2)\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.4: determine_Wn_zeta_and_Mp.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,zeta_and_Mp\n",
+"//example 11_4\n",
+"//page 471\n",
+"s=%s;\n",
+"num=1;\n",
+"den=sym('s*(1+0.5*s)*(1+0.2*s)');\n",
+"c=num/den;\n",
+"c=simple(c);\n",
+"disp(c,'C(s)/E(s)=');\n",
+"G=c;\n",
+"H=1;\n",
+"CL=G/(1+G*H);\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"A=pfss((10/(s^3+7*s^2+10*s+10)));\n",
+"d=denom(A(1));\n",
+"b=coeff(denom(A(1)))\n",
+"printf('for oscillatory roots:')\n",
+"Wn=sqrt(b(1,1));//natural_frequency\n",
+"//2*zeta*Wn=1.5;\n",
+"zeta=1.5/(2*Wn);//damping ratio\n",
+"Mp=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"disp(Wn,'natural_frequency,Wn=');\n",
+"disp(zeta,'damping ratio,zeta=');\n",
+"disp(Mp,'%_peak_overshoot,Mp=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.5: time_response_for_unit_step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 11_6\n",
+"//page 474\n",
+"s=%s;\n",
+"syms t;\n",
+"G=(s+2)/(s*(s+1))\n",
+"H=1;\n",
+"CL=G/.H\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"y=ilaplace(CL,s,t);\n",
+"disp(y,'c(t)=');\n",
+"b=denom(CL)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"tr=(%pi-atan(sqrt(1-zeta^2)/zeta))/(Wn*sqrt(1-zeta^2))\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"disp(tr,'rise time=');\n",
+"disp(Mp,'max. peak overshoot=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.7: time_response_for_unit_step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 11_7\n",
+"//page 475\n",
+"s=%s;\n",
+"syms t;\n",
+"CL=(s+2)/(s^2+2*s+2)\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"y=ilaplace(CL,s,t);\n",
+"disp(y,'c(t)=');\n",
+"b=denom(CL)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"Tp=%pi/Wd//peak time\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'max. peak overshoot=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.8: time_response_for_unit_step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 11_8\n",
+"//page 476\n",
+"s=%s;\n",
+"syms t;\n",
+"G=(20)/((s+1)*(s+5))\n",
+"H=1;\n",
+"CL=G/.H\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"y=ilaplace(CL,s,t);\n",
+"disp(y,'c(t)=');\n",
+"b=denom(CL)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"Tp=%pi/Wd//peak time\n",
+"t=(2*%pi)/(Wn*sqrt(1-zeta^2))//period of oscillation\n",
+"ts=4/(zeta*Wn)//settling time\n",
+"N=Wd/(2*%pi)*ts//no. of oscillations completed before reaching steady state\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'max. peak overshoot=');\n",
+"disp(t,'period of oscillation');\n",
+"disp(N,'no. of oscillations completed before reaching steady state=');\n",
+"disp(ts,'settling time=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11.9: time_response_for_unit_step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 11_9\n",
+"//page 476\n",
+"s=%s;\n",
+"syms t;\n",
+"CL=(4*s+4)/(s^2+2*s+5)\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"y=ilaplace(CL,s,t);\n",
+"disp(y,'c(t)=');\n",
+"b=denom(CL)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"Tp=%pi/Wd//peak time\n",
+"disp(Tp,'peak time=');\n",
+"disp(Mp,'max. peak overshoot=');"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/12-CLASSIFIED_SOLVED_EXAMPLES.ipynb b/Linear_Control_Systems_by_B_S_Manke/12-CLASSIFIED_SOLVED_EXAMPLES.ipynb
new file mode 100644
index 0000000..2821b89
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/12-CLASSIFIED_SOLVED_EXAMPLES.ipynb
@@ -0,0 +1,1667 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 12: CLASSIFIED SOLVED EXAMPLES"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.10: Determine_Unit_Step_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_unit_step_response\n",
+"//example 12.10\n",
+"//page 524\n",
+"s=%s;\n",
+"syms t;\n",
+"CL=sym('1/((s+1)*(s^2+1))')\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s);\n",
+"a=s*d;\n",
+"c=ilaplace(d,s,t);\n",
+"disp(c,'c(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.11: Determine_Unit_Step_and_Unit_Impulse_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_unit_step_and_unit_impulse_response\n",
+"//example 12.11\n",
+"//page 524\n",
+"s=%s;\n",
+"syms t;\n",
+"G=sym('8/(s+1)');\n",
+"H=sym('(1/2*s)');\n",
+"CL=G/(1+G*H);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s);\n",
+"disp(d,'C(s)=');\n",
+"c=ilaplace(d,s,t);\n",
+"disp(c,'unit step response,c(t)=');\n",
+"//for unit impulse response R(s)=1; \n",
+"e=CL*(1);\n",
+"disp(e,'C(s)=');\n",
+"ct=ilaplace(e,s,t);\n",
+"disp(ct,'unit impulse response,c(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.12: Determine_Wn_Wd_zeta_and_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,Wd,zeta_and_steady_state_error\n",
+"//example 12_12\n",
+"//page 526\n",
+"s=%s;\n",
+"G=sym('20/(s*(s^2+6*s+6))');\n",
+"H=0.25;\n",
+"CL=G/(1+G*H);\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"printf('the char. eq is:')\n",
+"disp('s^2+s+1=0')\n",
+"Wn=sqrt(1)//natural_frequency\n",
+"//2*zeta*Wn=1\n",
+"zeta=1/(2*Wn);//damping ratio\n",
+"d=zeta*Wn;//damping_factor\n",
+"z=sqrt(1-zeta^2);\n",
+"Wd=Wn*z;//damped_frequency_of_oscillation\n",
+"Mp=exp((-zeta*%pi)/z)*100;//%_max.peak_overshoot\n",
+"ts=4/(zeta*Wn);//settling_time\n",
+"tp=%pi/(Wn*sqrt(1-zeta^2));//peak_time\n",
+"tu=2*%pi/(Wn*sqrt(1-zeta^2));//first under shoot\n",
+"ti=tu-tp;//time interval between max. and min. values\n",
+"disp(Wn,'natural_frequency=');\n",
+"disp(zeta,'damping ratio=');\n",
+"disp(Wd,'damped_frequency_of_oscillation=');\n",
+"disp(Mp,'%_max.peak_overshoot=');\n",
+"disp(ts,'settling_time=');\n",
+"disp(tp,'peak_time=');\n",
+"disp(ti,'time_interval_between_max_and_min_values=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.13: Determine_Wn_Wd_zeta_and_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,Wd,zeta_and_steady_state_error\n",
+"//example 12_13\n",
+"//page 527\n",
+"syms Kp K Kd T \n",
+"s=%s;\n",
+"//exec series.sce;\n",
+"//exec parallel.sce;\n",
+"a=(Kp+s*Kd)*K\n",
+"b=1/(s*(s*T+1))\n",
+"G=series(a,b)\n",
+"H=1;\n",
+"er=1/(1+G*H)\n",
+"disp(er,'E(s)/R(s)=');\n",
+"R=1/s^2\n",
+"E=R*er\n",
+"ess=limit(s*E,s,0)\n",
+"disp(ess,'steady state error,ess=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.15: Stability_Using_Routh_Hurwitz_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 12.15\n",
+"//page 529\n",
+"s=%s;\n",
+"syms K\n",
+"G=sym('K/(s*(s^2+s+1)*(s+5)');\n",
+"H=1;\n",
+"CH=(s*(s^2+s+1)*(s+5)+K)\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2)/routh(2,1)),K,0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0,0]\n",
+"routh=[routh;K,0,0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable:');\n",
+"disp('((5.1*5-6*K)/5.1)>0 and K>0');\n",
+"disp('which gives:');\n",
+"disp('0<K<4.25');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.16: Stability_Using_Routh_Hurwitz_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 12.16\n",
+"//page 530\n",
+"s=%s;\n",
+"syms K\n",
+"CH=s^4+2*s^3+10*s^2+(K-10)*s+K\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2)/routh(2,1)),K,0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"//routh=[routh;K,0,0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable,following condition should be satisfied');\n",
+"disp('K<30,K<22.9 and K>13.1,K>0')\n",
+"disp('which gives,')\n",
+"disp('13.1<K<22.9');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.17: Stability_Using_Routh_Hurwitz_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 12.17\n",
+"//page 530\n",
+"s=%s;\n",
+"syms K\n",
+"G=sym('K/((s^3+3*s+2)*(s^2+6*s+24))');\n",
+"H=1;\n",
+"CH=((s^3+3*s+2)*(s^2+6*s+24)+K)\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"//routh=[routh;K,0,0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable,following condition should be satisfied');\n",
+"disp('78.84-0.259K>0')\n",
+"disp('which gives limiting value of K')\n",
+"disp('K<288.9');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.18: Stability_Using_Routh_Hurwitz_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 12.18\n",
+"//page 531\n",
+"s=%s;\n",
+"A=s^5+s^4+4*s^3+4*s^2+s+1;\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"routh=[b([6 4 2]);b([5 3 1])]\n",
+"routh1=routh;\n",
+"c=[routh(1,1),routh(1,3);routh(2,1),routh(2,3)]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(c)/routh(2,1),0]\n",
+"disp('since all elements of third row are zero, so we make auxiliary equation')\n",
+"A=sym('s^4+4*s^2+1')//auxiliary equation\n",
+"B=diff(A,s)\n",
+"routh=[routh1;4,8,0]\n",
+"d=[routh(2,1),routh(2,3);routh(3,1),routh(3,3)]\n",
+"routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(d)/routh(3,1),0]\n",
+"routh2=routh\n",
+"routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0]\n",
+"routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0];\n",
+"disp(routh,'routh=')\n",
+"disp('stability is examined as below . since roots of auxiliary eq are also roots of characterstics eq')\n",
+"A=s^4+4*s^2+1\n",
+"b=roots(A)\n",
+"disp('since the equation has non repeating roots on s plane imaginary axis.hence system are unstable' )\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.19: Stability_Using_Routh_Hurwitz_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 12.19\n",
+"//page 531\n",
+"s=%s;\n",
+"A=s^5+s^4+4*s^3+4*s^2+4*s+4;\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"routh=[b([6,4,2]);b([5 3 1])]\n",
+"routh1=routh;\n",
+"c=[routh(1,1),routh(1,3);routh(2,1),routh(2,3)]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(c)/routh(2,1),0]\n",
+"disp('since all elements of third row are zero, so we make auxiliary equation')\n",
+"A=sym('s^4+4*s^2+4')//auxiliary equation\n",
+"B=diff(A,s)\n",
+"routh=[routh1;4,8,0]\n",
+"d=[routh(2,1),routh(2,3);routh(3,1),routh(3,3)]\n",
+"routh=[routh;-det(routh(2:3,1:2))/routh(3,1),-det(d)/routh(3,1),0]\n",
+"routh2=routh\n",
+"routh=[routh;-det(routh(3:4,1:2))/routh(4,1),0,0]\n",
+"disp('since all elements of fifth row are zero, so we make auxiliary equation')\n",
+"A=sym('2*s^2+4')//auxiliary equation\n",
+"B=diff(A,s)\n",
+"routh=[routh2;4,0,0]\n",
+"routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0];\n",
+"disp(routh,'routh=')\n",
+"disp('stability is examined as below . since roots of auxiliary eq are also roots of characterstics eq')\n",
+"A=s^4+4*s^2+4\n",
+"b=roots(A)\n",
+"disp('since the equation has multiple roots on s plane imaginary axis.hence system are unstable' )\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.1: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 12.1\n",
+"//page 515\n",
+"// we are solving this problem from signal flow graph approach\n",
+"syms G H;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=1*G*1\n",
+"P2=1;\n",
+"L1=-G;\n",
+"L2=-G*H;\n",
+"L3=G*H;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.21: Determine_Frequency_of_Oscillations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_frequency_of_oscillations\n",
+"//example 12.21\n",
+"//page 533\n",
+"s=%s;\n",
+"syms K\n",
+"G=sym('K*(s*(2*s+1))/(s^3+3*s+20)');\n",
+"H=1;\n",
+"CH=((s^3+3*s+20)+K*(s*(2*s+1)))\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"routh=[b([4,2]);b([3,1])]\n",
+"routh=[routh;-det(routh(1:2,1:2)/routh(2,1)),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0]\n",
+"disp(routh,'routh=')\n",
+"disp('for sustained oscillations:');\n",
+"disp('2*K^2+6*K-20=0')\n",
+"disp('which gives K')\n",
+"disp('K=2');\n",
+"disp('freq of oscillations is calculated by solving equation formed by s^2 row of the routh table')\n",
+"K=2\n",
+"k=2\n",
+"A=2*k*s^2+20\n",
+"r=roots(A)\n",
+"disp(%i*r(2),'frequency of oscillations=' )\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.23_iii: Stability_Using_Nyquist_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 12_23_iii\n",
+"//page 535\n",
+"disp('for K=10')\n",
+"g=(10*(s+10)*(s+40))/(s*(s+1)*(s+4));\n",
+"g1=(10*(s1+10)*(s1+40))/(s1*(s1+1)*(s1+4));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"//mtlb_axis([-1.5 0.2 -0.3 0.3]);\n",
+"xtitle('Nyquist plot of (0.1*(s+10)*(s+40))/(s*(s+1)*(s+4))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is encircled once in clockwise and once in anti clockwise direction by Nyquist plot ,so N=0 and P=0')\n",
+"N=0;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.23_ii: Stability_Using_Nyquist_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 12_23_ii\n",
+"//page 535\n",
+"disp('for K=1')\n",
+"g=(0.1*(s+10)*(s+40))/(s*(s+1)*(s+4));\n",
+"g1=(0.1*(s1+10)*(s1+40))/(s1*(s1+1)*(s1+4));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"//mtlb_axis([-3 0.5 -0.6 0.6]);\n",
+"xtitle('Nyquist plot of (0.1*(s+10)*(s+40))/(s*(s+1)*(s+4))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is encircled twice clockwise by Nyquist plot ,so N=2 and P=0(given)')\n",
+"N=-2;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=2,there are two roots of closed loop characterstics eq having positive real part, hence system is unstable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.23_i: Stability_Using_Nyquist_Criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 12_23_i\n",
+"//page 535\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=0.1')\n",
+"g=(0.1*(s+10)*(s+40))/(s*(s+1)*(s+4));\n",
+"g1=(0.1*(s1+10)*(s1+40))/(s1*(s1+1)*(s1+4));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"//mtlb_axis([-1.5 0.2 -0.3 0.3]);\n",
+"xtitle('Nyquist plot of (0.1*(s+10)*(s+40))/(s*(s+1)*(s+4))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is not encircled clockwise by Nyquist plot ,so N=0 and P=0')\n",
+"N=0;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.27: Gain_and_Phase_Margin.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:gain_and_phase_margin\n",
+"//example 12_27\n",
+"//page543\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=0.5')\n",
+"g=(0.5)/(s*(s+1)^2);\n",
+"GH=syslin('c',g);\n",
+"nyquist(GH);\n",
+"//mtlb_axis([-5 1 -500 500]);\n",
+"xtitle('Nyquist plot of (2.5*3)/(s*(0.4*s+1)*(0.2*s+1))')\n",
+"pm=p_margin(GH)\n",
+"disp(pm,'phase margin=')\n",
+"gm=g_margin(GH)\n",
+"disp(gm,'gain margin=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.2: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 12.2\n",
+"//page 516\n",
+"// we are solving this problem from signal flow graph approach\n",
+"syms G1 G2 G3 G4\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1;\n",
+"P2=G2;\n",
+"P3=-G1*G2*G3;\n",
+"P4=G1*G2*G4;\n",
+"L1=-G1*G2*G3*G4;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D3=1;\n",
+"D4=1;\n",
+"D=1-(L1);\n",
+"Y=(P1*D1+P2*D2+P3*D3+P4*D4)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.33: Determine_Close_Loop_Stability.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_close_loop_stability\n",
+"//example 12_33\n",
+"//page 550\n",
+"s=%s;\n",
+"g=(720*(s+1.25))/(s*(s+10)*(s^2+2*s+9));\n",
+"G=syslin('c',g)\n",
+"fmin=0.1; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"show_margins(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq=');\n",
+"show_margins(G);\n",
+"disp('since gain and phase margin are both negative so system is unstable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.3: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 12.3\n",
+"//page 517\n",
+"// we are solving this problem from signal flow graph approach\n",
+"syms G1 G2 G3 G4 H2 H1 H3\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G2*G4;\n",
+"P2=G2*G3*G4;\n",
+"P3=G1*G3*G4;\n",
+"L1=-G4*H1;\n",
+"L2=-G3*G4*H1*H2;\n",
+"L3=-G1*G3*G4*H1*H2*H3\n",
+"D1=1;\n",
+"D2=1;\n",
+"D3=1;\n",
+"D=1-(L1+L2+L3);\n",
+"Y=(P1*D1+P2*D2+P3*D3)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.42: Root_Locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 12_42\n",
+"//page 562\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+2)*(s+4))\n",
+"//since Mp=40%, so .4=exp((-zeta*%pi)/(sqrt(1-zeta^2))\n",
+"zeta=0.3\n",
+"//from given data \n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+2)*(s+4))+K\n",
+"K=sym('-(s^3+6*s^2+8*s)')\n",
+"d=diff(K,s)\n",
+"e=-3*s^2-12*s-8 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-0.842 is break away point sinc it lies on root locus')\n",
+"CH=sym('s^3+6*s^2+8*s+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(48-K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=48');\n",
+"K=48;\n",
+"k=48\n",
+"a=6*s^2+48//intersection of root locus with imaginary plane\n",
+"r=roots(a)\n",
+"g=k/(s*(s+2)*(s+4))\n",
+"G=syslin('c',g)\n",
+"evans(g,8)\n",
+"xgrid(2)\n",
+"disp('the line theta=acos(zeta)=72.5 intersects root locus at sa=(-0.5+i1.65)')\n",
+"disp('the value of K at s=sa is find to be 14.87 for Mp=40%')\n",
+"K=14.87\n",
+"ts=4/0.5 //ts=4/(zeta*wn)\n",
+"Kv=limit(s*GH,s,0)\n",
+"Kv=eval(Kv)\n",
+"Kv=float(Kv)\n",
+"disp(Kv,'Kv=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.43: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12.43\n",
+"//page 564\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+2)*(s^2+2*s+2))\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+2)*(s^2+2*s+2))+K\n",
+"CH=sym('s^4+4*s^3+6*s^2+4*s+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"K=sym('s^4+4*s^3+6*s^2+4*s')\n",
+"d=diff(K,s)\n",
+"e=-(4*s^3+12*s^2+12*s+4)\n",
+"r=roots(e)\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('((20-4K)/5)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=5');\n",
+"K=5;\n",
+"k=5\n",
+"a=5*s^2+5//intersection of root locus with s plane\n",
+"r=roots(a)\n",
+"disp(r,'intersection point with imaginary axis=')\n",
+"g=k/(s*(s+2)*(s^2+2*s+2))\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)\n",
+"disp('angle of departure=-90 and +90')\n",
+"disp('breakaway point is -1 and +j and -j')\n",
+"disp('on solving we find K=1')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.44: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12.44\n",
+"//page 565\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/((s^2+2*s+5)*(s^2+2*s+2))\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=((s^2+2*s+5)*(s^2+2*s+2))+K\n",
+"CH=sym('((s^2+2*s+5)*(s^2+2*s+2))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"K=sym('-(s^2+2*s+5)*(s^2+2*s+2)')\n",
+"d=diff(K,s)\n",
+"e=-(4*s^3+12*s^2+22*s+14)\n",
+"r=roots(e)\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('((7.5*14-4(K+10)/7.5)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=16.25');\n",
+"K=16.25;\n",
+"k=16.25\n",
+"a=7.5*s^2+26.25//intersection of root locus with s plane\n",
+"r=roots(a)\n",
+"g=k/((s^2+2*s+5)*(s^2+2*s+2))\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)\n",
+"disp(r,'the point of intersection of root locus with imaginary axis =')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.45: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12.45\n",
+"//page 567\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K*(s+1)/(s*(s+2)*(s^2+4*s+8))\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=((s*(s+2)*(s^2+4*s+8)))+K*(s+1)\n",
+"CH=sym('((s*(s+2)*(s^2+4*s+8)))+K*(s+1)');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(K^2-28*K-1280)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=52.4 and -24.42');\n",
+"K=52.4;//considering positive value\n",
+"k=52.4\n",
+"a=((80-52.4)/6)*s^2+52.4//intersection of root locus with imaginary axis\n",
+"r=roots(a)\n",
+"g=k*(s+1)/(s*(s+2)*(s^2+4*s+8))\n",
+"G=syslin('c',g)\n",
+"clf();\n",
+"evans(g,10)\n",
+"xgrid(2)\n",
+"disp(r,'the point of intersection of root locus with imaginary axis =')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.46: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12.46\n",
+"//page 570\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*((s+6)^2))\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*((s+6)^2))+K\n",
+"CH=sym('(s*((s+6)^2))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"K=sym('-(s*((s+6)^2))')\n",
+"d=diff(K,s)\n",
+"e=3*s^2+24*s+36 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-2 is break away point sinc it lies on root locus')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(-(K-432)/12)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=432');\n",
+"K=432;//considering positive value\n",
+"k=432\n",
+"a=12*s^2+k//intersection of root locus with imaginary axis plane\n",
+"r=roots(a)\n",
+"g=k/(s*((s+6)^2))\n",
+"G=syslin('c',g)\n",
+"clf();\n",
+"evans(g,5)\n",
+"xgrid(2)\n",
+"disp(r,'the point of intersection of root locus with imaginary axis =')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.48: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12_48\n",
+"//page 574\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+2)*(s+4))\n",
+"zeta=0.277\n",
+"//from given data \n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+2)*(s+4))+K\n",
+"K=sym('-(s^3+6*s^2+8*s)')\n",
+"d=diff(K,s)\n",
+"e=-3*s^2-12*s-8 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-0.85 is break away point sinc it lies on root locus')\n",
+"CH=sym('s^3+6*s^2+8*s+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(48-K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=48');\n",
+"K=48;\n",
+"k=48\n",
+"a=6*s^2+48//intersection of root locus with imaginary plane\n",
+"r=roots(a)\n",
+"g=k/(s*(s+2)*(s+4))\n",
+"G=syslin('c',g)\n",
+"evans(g,8)\n",
+"xgrid(2)\n",
+"disp('the line theta=acos(zeta)=73.9 intersects root locus at sa=(-0.5+i1.66)')\n",
+"disp('the value of K at s=sa is find to be 15 for zeta=0.277')\n",
+"K=15\n",
+"k=15\n",
+"disp(r,'the point of intersection of root locus with imaginary axis =')\n",
+"g=k/(s*(s+2)*(s+4))\n",
+"cl=g/(1+g)\n",
+"disp(cl,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.49: Root_Locus_and_Value_of_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_value_of_K\n",
+"//example 12.49\n",
+"//page 576\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=(K*(s+4))/(s+2)^2\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s+2)^2+(K*(s+4))\n",
+"CH=sym('((s+2)^2)+K*(s+4)');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"K=sym('((s+2)^2/(s+4))')\n",
+"d=diff(K,s)\n",
+"e=(s+2)*(s+6)\n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-2 and -6 is break away point')\n",
+"g=(s+4)/((s+2)^2)\n",
+"G=syslin('c',g)\n",
+"clf();\n",
+"evans(g,10)\n",
+"xgrid(2)\n",
+"disp('for wd=2rad/sec,the point on root locus is s=-4+j2')\n",
+"disp('the value of K at s=-4+j2 is 4')\n",
+"K=4\n",
+"k=4\n",
+"g=k*(s+4)/((s+2)^2)\n",
+"cl=g/(1+g)\n",
+"disp(cl,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.4: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 12.4\n",
+"//page 518\n",
+"// we are solving this problem from signal flow graph approach\n",
+"syms G1 G2 \n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1;\n",
+"P2=G2;\n",
+"P3=G1*G2;\n",
+"P4=G1*G2;\n",
+"L1=-G1;\n",
+"L2=-G2;\n",
+"L3=G1*G2;\n",
+"L4=-G1*G2;\n",
+"L5=-G1*G2;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D3=1;\n",
+"D4=1;\n",
+"D=1-(L1+L2+L3+L4+L5);\n",
+"Y=(P1*D1+P2*D2+P3*D3+P4*D4)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.50: Root_Locus_and_Closed_loop_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_close_loop_transfer_function\n",
+"//example 12.50\n",
+"//page 578\n",
+"s=%s\n",
+"K=8\n",
+"G=K/(s*(s+4))\n",
+"H=1;\n",
+"GH=G*H\n",
+"G=syslin('c',G)\n",
+"evans(G,8)\n",
+"xgrid(2)\n",
+"CH=s*(s+4)+K\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"r=roots(CH)\n",
+"disp(r,'the point at which K=8')\n",
+"cl=G/(1+GH)\n",
+"disp(cl,'C(s)/R(s)=')\n",
+"\n",
+"\n",
+"\n",
+"disp('part b')\n",
+"g=K/(s+4)\n",
+"h=1/s\n",
+"gh=g*h\n",
+"CL=g/(1+gh)\n",
+"disp(CL,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.51: Root_Locus_and_Gain_and_Phase_Margin.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_and_gain,phase_margin\n",
+"//example 12.51\n",
+"//page 580\n",
+"s=%s;\n",
+"K=3.46\n",
+"G=K/(s*(s+1)*(s+2))\n",
+"G=syslin('c',G)\n",
+"clf();\n",
+"evans(G,20)\n",
+"xgrid(2)\n",
+"[gm,freq_gm]=g_margin(G)\n",
+"[pm,freq_pm]=p_margin(G)\n",
+"disp(gm,'gain_margin=',freq_gm*2*%pi,'gain_margin_freq=')\n",
+"disp(pm,'phase_margin=',freq_pm*2*%pi,'phase_margin_freq=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.54: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 12_54\n",
+"//page 583\n",
+"s=%s;\n",
+"g=5*(s+2)/(s*(s+1)*(s+5));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.55: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 12_55\n",
+"//page 585\n",
+"s=%s;\n",
+"g=50/(s*(s^2+0.5*s+50));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.56: Obtain_State_Transistion_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_transistion_matrix\n",
+"//example 12_56\n",
+"//page 586\n",
+"s=%s;\n",
+"syms t\n",
+"A=[0 1;0 -3]\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"//for calculating state transistion matrix\n",
+"ip=[0 0;0 0]\n",
+"i=1;\n",
+"j=1;\n",
+"for i=1:2\n",
+" for j=1:2\n",
+" if(i==2 & j==1)\n",
+" else\n",
+" ip(i,j)=ilaplace(r(i,j),s,t);\n",
+" j=j+1;\n",
+" end\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"r(2,1)=0\n",
+"disp(ip,'state transistion matrix,ip(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.57: Obtain_Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response\n",
+"//example 12_57\n",
+"//page 586\n",
+"s=%s;\n",
+"syms t\n",
+"A=[0 1;-2 -3]\n",
+"B=[1 0]'\n",
+"x0=[0 0]'\n",
+"u=1/(s+1)\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"m=r*B*(1/(s+1));\n",
+"//for calculating zero state response\n",
+"x=[0;0]\n",
+"x(1,1)=ilaplace(m(1,1),s,t);\n",
+"x(2,1)=ilaplace(m(2,1),s,t);\n",
+"disp(x,'time response of the system,x(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.59: Obtain_Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response\n",
+"//example 12_59\n",
+"//page 590\n",
+"s=%s;\n",
+"syms t\n",
+"A=[-1 0;1 -1]\n",
+"B=[0 1]'\n",
+"x0=[1 0]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"m=r*B*(1/s)\n",
+"r1=r*x0\n",
+"X=r1+m\n",
+"//for calculating zero state response\n",
+"x=[0;0]\n",
+"x(1,1)=ilaplace(X(1,1),s,t);\n",
+"x(2,1)=ilaplace(X(2,1),s,t);\n",
+"disp(x,'zero input response of the system,x(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.5: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 12.5\n",
+"//page 518\n",
+"// we are solving this problem from signal flow graph approach\n",
+"syms G1 G2 G3 G4 G5 H1 H2\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G4*G5;\n",
+"P2=G1*G2*G3*G5;\n",
+"L1=-G3*G5;\n",
+"L2=-G3*G5*H2;\n",
+"L3=-G1*G4*G5*H1;\n",
+"L4=-G1*G2*G3*G5*H1;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3+L4);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.61: Obtain_Transfer_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_transfer_matrix\n",
+"//example 12_61\n",
+"//page 592\n",
+"s=%s;\n",
+"syms t\n",
+"A=[-1 -1;3 -5]\n",
+"B=[1 1]'\n",
+"C=[1 2]\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B\n",
+"disp(G,'transfer_matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.7: Determine_Peak_Time_and_Peak_Overshoot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_peak_time_and_peak_overshoot\n",
+"//example 12.7\n",
+"//page 520\n",
+"s=%s;\n",
+"syms t;\n",
+"G=sym('(s+2)/(s*(s+1))')//G(s)\n",
+"H=1;\n",
+"CL=G/(1+G*H);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s);\n",
+"a=s*d;\n",
+"disp(d,'C(s)=');\n",
+"c=ilaplace(d,s,t);\n",
+"disp(c,'c(t)=');\n",
+"//for peak time we get tp=3*%pi/4\n",
+"tp=3*%pi/4\n",
+"Cmax=1-(exp(-tp)*cos(tp));\n",
+"Css=limit(a,s,0);\n",
+"disp(Css,'Css=');\n",
+"Mp=((Cmax-Css)/Css)*100\n",
+"Mp=float(Mp)\n",
+"disp(Mp,'peak_overshoot=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.8: Time_Response_and_Peak_Overshoot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_and_peak_overshoot\n",
+"//example 12.8\n",
+"//page 521\n",
+"s=%s;\n",
+"syms t;\n",
+"num=sym('8*(s+1)');\n",
+"den=sym('(s^2+2*s+2)');\n",
+"CL=num/den;\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s);\n",
+"disp(d,'C(s)=');\n",
+"c=ilaplace(d,s,t);\n",
+"disp(c,'c(t)=');\n",
+"//for peak time we get tp=%pi/2\n",
+"t=%pi/2\n",
+"a=s*d;\n",
+"a=simple(a)\n",
+"Cmax=4*(1+1.414*exp(-t)*sin(t-(%pi/4)))\n",
+"Css=limit(a,s,0);\n",
+"disp(Css,'Css=');\n",
+"Mp=((Cmax-Css)/Css)*100\n",
+"Mp=float(Mp)\n",
+"disp(Mp,'peak_overshoot=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12.9: Determine_Peak_Overshoot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:determine_peak_overshoot\n",
+"//example 12.9\n",
+"//page 523\n",
+"s=%s;\n",
+"syms t K;\n",
+"CL=sym('(s+1)/(s^2+2*s+5)');\n",
+"CL=K*CL;\n",
+"disp(CL,'C(s)/R(s)=')\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s)\n",
+"Css=limit(s*d,s,0)\n",
+"disp(Css,'Css=');\n",
+"//since Css=0.8 (given)\n",
+"K=0.8*5;\n",
+"CL=eval(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//for unit step response R(s)=1/s; \n",
+"d=CL*(1/s)\n",
+"disp(d,'C(s)=');\n",
+"c=ilaplace(d,s,t);\n",
+"disp(c,'c(t)=');\n",
+"//for peak time we get tp=0.785\n",
+"t=0.785\n",
+"a=s*d;\n",
+"a=simple(a)\n",
+"Cmax=(4/5)*(1-exp(-t)*cos(2*%pi/4)+exp(-t)*2*sin(2*%pi/4))\n",
+"Css=limit(a,s,0)\n",
+"disp(Css,'Css=');\n",
+"Mp=((Cmax-Css)/Css)*100\n",
+"Mp=float(Mp)\n",
+"disp(Mp,'peak_overshoot=')"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/2-TRANSFER_FUNCTIONS.ipynb b/Linear_Control_Systems_by_B_S_Manke/2-TRANSFER_FUNCTIONS.ipynb
new file mode 100644
index 0000000..03c9ba5
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/2-TRANSFER_FUNCTIONS.ipynb
@@ -0,0 +1,96 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 2: TRANSFER FUNCTIONS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2.4_1: pole_zero_plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:pole_zero_Plot\n",
+"// example 2.4.1\n",
+"//page 19\n",
+"//transfer function:G(s)=(1/2((s^2+4)*(1+2.5*s))/((s^2+2)*(1+0.5*s)))\n",
+"s=%s;\n",
+"G=syslin('c',(1/2*((s^2+4)*(1+2.5*s))/((s^2+2)*(1+0.5*s))));\n",
+"disp(G,'G(s)=');\n",
+"x=plzr(G)\n",
+"xtitle('pole-zero_configuration','Real_part','Img_part');\n",
+"// value at s=2\n",
+"a=2;\n",
+"g=(1/2*((a^2+4)*(1+2.5*a))/((a^2+2)*(1+0.5*a)));\n",
+"disp(g,'G(2)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2.4_2: final_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:final_value\n",
+"// example 2.4.2\n",
+"//page 20\n",
+"//refer to fig.2.4.2 given on page 20\n",
+"//poles are located at s=0,-2 and -4\n",
+"//zero at s=-3\n",
+"s=%s;\n",
+"syms K;\n",
+"g=syslin('c',((s+3))/(s*(s+2)*(s+4)));//transfer function\n",
+"G=K*g;//transfer function\n",
+"disp(G,'G(s)=');\n",
+"//G(s)=3.2 at s=1;\n",
+"//on solving we find K=12\n",
+"K=12;\n",
+"G=K*g;\n",
+"disp(G,'G(s)=')"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/3-BLOCK_DIAGRAMS.ipynb b/Linear_Control_Systems_by_B_S_Manke/3-BLOCK_DIAGRAMS.ipynb
new file mode 100644
index 0000000..f34542d
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/3-BLOCK_DIAGRAMS.ipynb
@@ -0,0 +1,601 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 3: BLOCK DIAGRAMS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_10: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.10\n",
+"//page 43\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 G5 H1 H2 H3;\n",
+"a=parallel(G3,G4);\n",
+"//shift off the take off point before block 'a' to after block 'a'\n",
+"b=1/a;\n",
+"d=1;\n",
+"c=G2/(1+G2*d);\n",
+"e=parallel(H1,b);\n",
+"f=series(c,a);\n",
+"g=series(H2,e);\n",
+"h=f/(1+f*g);\n",
+"h=simple(h);\n",
+"i=series(h,G1);\n",
+"y=i/(1+i*H3);\n",
+"y=simple(y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_11: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.11\n",
+"//page 45\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 H1 H2 H3;\n",
+"a=G4/.H1;\n",
+"//shift the summing point after block G3 towards left of block G3\n",
+"b=G2/G3;\n",
+"c=series(a,G3);\n",
+"d=c/(1+c*H2);\n",
+"d=simple(d)\n",
+"//shift the summing point before block G1 towards right of block G1\n",
+"e=G1*H3;\n",
+"f=d/(1+d*e);\n",
+"f=simple(f)\n",
+"g=parallel(G1,b);\n",
+"g=simple(g);\n",
+"y=series(g,f)\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_12: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.12\n",
+"//page 47\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 H1 H2 H3;\n",
+"//shift the summing point before block G1 towards right of block G1\n",
+"//shift the summing point after block G3 towards left of block G3\n",
+"a=G2/G1\n",
+"b=H3/G3;\n",
+"c=G1/.H1\n",
+"d=G3/.H2\n",
+"e=series(G4,d)\n",
+"//shift the summing point after block e towards left of block e\n",
+"g=1/e\n",
+"f=series(a,g);\n",
+"f=simple(f)\n",
+"h=parallel(f,1);\n",
+"h=simple(h)\n",
+"i=e/(1+e*b);\n",
+"i=simple(i)\n",
+"j=series(c,h);\n",
+"y=series(j,i);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_13: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.13\n",
+"//page 49\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 H1 H2;\n",
+"//shift the summing point after block H2 towards right of block H2\n",
+"//shift the summing point after block H1 towards right of block H2\n",
+"a=H1*H2\n",
+"b=parallel(G1,G2)\n",
+"c=G4/.a\n",
+"d=series(G3,c)\n",
+"e=d/(1+d*H2);\n",
+"e=simple(e)\n",
+"f=series(b,e)\n",
+"y=f/(1+f*a);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=');\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_14: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.14\n",
+"//page 50\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 H1 H2 R D;\n",
+"a=parallel(G1,G2)\n",
+"b=G3/.H2\n",
+"c=series(a,b)\n",
+"//inorder to determine C(s)/R(s) consider D=0\n",
+"d=series(c,G4);\n",
+"y=d/(1+d*H1);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')\n",
+"// now consider R=0 for calculating C(s)/D(s)\n",
+"e=series(c,H1)\n",
+"z=G4/(1+G4*e);\n",
+"z=simple(z);\n",
+"disp(z,'C(s)/D(s)=');\n",
+"x=(y*R)+(z*D);\n",
+"x=simple(x);\n",
+"printf('total output');\n",
+"disp(x,'C(s)')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_15: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.15\n",
+"//page 52\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 H1 H2 H3 D1 D2 R;\n",
+"a=G2/.H2\n",
+"b=a/(1+a*H3);\n",
+"b=simple(b)\n",
+"//inorder to determine C(s)/R(s) consider D1=0,D2=0\n",
+"c=series(b,G1)\n",
+"y=c/(1+c*H1);\n",
+"y=simple(y)\n",
+"disp(y,'C(s)/R(s)');\n",
+"// now consider R=0,D2=0 for calculating C(s)/D1(s)\n",
+"d=series(G1,H1);\n",
+"z=b/(1+b*d);\n",
+"z=simple(z)\n",
+"disp(z,'D1(s)/R(s)');\n",
+"// now consider R=0,D1=0 for calculating C(s)/D2(s)\n",
+"e=G1*(-H1);\n",
+"f=series(b,e);\n",
+"x=f/(1+f);\n",
+"x=simple(x);\n",
+"disp(x,'D2(s)/R(s)');\n",
+"out=(y*R)+(z*D1)+(x*D2);\n",
+"out=simple(out);\n",
+"disp(out,'C(s)');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_1: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.1\n",
+"//page 32\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1;\n",
+"// shifting take off point after block G2 to a position before block G2\n",
+"a= G2*H1;\n",
+"b=parallel(G2,G3);\n",
+"//shifting take off point before (G2+G3) to After (G2+G3)\n",
+"c=a/b;\n",
+"m=1;\n",
+"d=b/(1+m*b);\n",
+"e=series(G1,d);\n",
+"y=(e/(1+c*e));\n",
+"y=simple (y);\n",
+"disp (y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_2: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.2\n",
+"//page 34\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1;\n",
+"// shifting take off point before block G1 to a position after block G1\n",
+"a=G1*H1;\n",
+"b=parallel(G1,G2);\n",
+"c=G3/.a\n",
+"y=series(b,c);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_3: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.3\n",
+"//page 35\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 G5 G6 H1 H2;\n",
+"//shift the takeof point placed before G2 towards right side of block G2\n",
+"a= G5/G2;\n",
+"b=parallel(G3,G4);\n",
+"c=series(b,G6);\n",
+"d=parallel(a,c);\n",
+"e=series(G1,G2);\n",
+"l=series(H1,d);\n",
+"g=e/.H2\n",
+"y=g/(1+g*l)\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_4: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.4\n",
+"//page 36\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1 H2;\n",
+"//shift the take off point placed before G1 to after block G1\n",
+"a=G3/G1;\n",
+"b=parallel(a,G2);\n",
+"//shift the take off point before block b towards right side of same block\n",
+"c=1/b;\n",
+"d=series(H1,c);\n",
+"e=series(G1,b);\n",
+"g=parallel(H2,d);\n",
+"y=e/(1+e*g);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_5: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.5\n",
+"//page 37\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1 H2 H3;\n",
+"//shift the take off point placed before G3 to after block G3\n",
+"a=H3/G3;\n",
+"b=G3/.H2;\n",
+"c=series(G2,b);\n",
+"//shift the summing point after block G1 to before block G1\n",
+"d=a/G1;\n",
+"e=G1/.H1;\n",
+"f=series(e,c);\n",
+"y=f/(1+f*d);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_6: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.6\n",
+"//page 38\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1;\n",
+"a=parallel(G1,G3);\n",
+"b=G2/.H1;\n",
+"y=series(a,b);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_7: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.7\n",
+"//page 39\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 H1 H2;\n",
+"//shift the take off point placed before G2 to after block G2\n",
+"a=G2*H1;\n",
+"//shift the take off point placed before G2 to after block G1 and shift the summing point before block G2 to before block G2\n",
+"//interchange consecutive summing point and shift the take off point placed before H2 to after block H2\n",
+"b=G2*H2;\n",
+"c=b*H1;\n",
+"d=parallel(G3,G2);\n",
+"e=1/.b\n",
+"f=series(d,e);\n",
+"g=G1/.a\n",
+"h=series(g,f);\n",
+"y=h/(1-h*c);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_8: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.8\n",
+"//page 41\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 G5 H1 H2;\n",
+"//shift the summing point before block G5 towards left of block G5\n",
+"a=G2*G5;\n",
+"b=G4/.H1;\n",
+"c=series(G5,H2);\n",
+"d=series(b,G3);\n",
+"e=d/(1+d*c);\n",
+"e=simple(e)\n",
+"f=parallel(G1,a);\n",
+"y=series(f,e);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.2_9: Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function\n",
+"// example 3.2.9\n",
+"//page 42\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"//exec parallel.sce;\n",
+"//exec series.sce;\n",
+"syms G1 G2 G3 G4 G5 H1 H2 H3;\n",
+"//shift the take off point placed before G3 to after block G3\n",
+"a=G5/G3;\n",
+"b=G1/.H1;\n",
+"c=series(b,G2);\n",
+"d=G3/.H2;\n",
+"e=parallel(G4,a);\n",
+"e=simple(e);\n",
+"f=series(c,d);\n",
+"g=series(f,e);\n",
+"g=simple(g);\n",
+"y=g/(1+g*H3);\n",
+"y=simple(y);\n",
+"disp (y,'C(s)/R(s)=');"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/4-SIGNAL_FLOW_GRAPHS.ipynb b/Linear_Control_Systems_by_B_S_Manke/4-SIGNAL_FLOW_GRAPHS.ipynb
new file mode 100644
index 0000000..046824b
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/4-SIGNAL_FLOW_GRAPHS.ipynb
@@ -0,0 +1,474 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 4: SIGNAL FLOW GRAPHS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.3_1: Overall_Transmittance.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transmittance\n",
+"// example 4.3.1\n",
+"//page 63\n",
+"syms G1 G2 H1;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"L1=-G1*H1;\n",
+"L2=-G2*H1;\n",
+"P1=G1;\n",
+"P2=G2;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y)\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.3_2: Overall_Transmittance.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transmittance\n",
+"// example 4.3.2\n",
+"//page 64\n",
+"syms G1 G2 H1;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1;\n",
+"P2=G2;\n",
+"L1=-G1*H1;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_10: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.10\n",
+"//page 72\n",
+"syms G1 G2 G3 G4 G5 H1 H2;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G2*G3*G4;\n",
+"P2=G1*G5*G4;\n",
+"L1=-G2*H1;\n",
+"L2=-G3*H2;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_1: Closed_Loop_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:closed_loop_transfer_function\n",
+"// example 4.4.1\n",
+"//page 64\n",
+"syms G1 G2 G3 H1;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G3;\n",
+"P2=G2*G3;\n",
+"L1=-G3*H1;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y)\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_2: Overall_Gai.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_gain\n",
+"// example 4.4.2\n",
+"//page 65\n",
+"syms a b c d e f g h\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"\n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=a*b*c*d;\n",
+"P2=a*g;\n",
+"L1=f;\n",
+"L2=c*e;\n",
+"L3=d*h;\n",
+"//nontouching loops are L1L2, L1L3\n",
+"L1L2=L1*L2;\n",
+"L1L3=L1*L3;\n",
+"D1=1;\n",
+"D2=1-L2;\n",
+"D=1-(L1+L2+L3)+(L1L2+L1L3);\n",
+"D=simple(D);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'x5/x1');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_3: to_find_various_signal_flow_graph_parameter.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:to_find_various_signal_flow_graph_parameter\n",
+"// example 4.4.3\n",
+"//page 66\n",
+"syms a b c d e f g h ij\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"//six independent path\n",
+"P1=a*b*d\n",
+"P2=e*f*h\n",
+"P3=a*j*h\n",
+"P4=e*i*d\n",
+"P5=-e*i*c*j*h\n",
+"P6=-a*j*g*i*d\n",
+"//3 INDIVIDUAL LOOPS\n",
+"L1=-b*c\n",
+"L2=-f*g\n",
+"L3=-i*c*j*g\n",
+"//NON TOUCHING LOOPS\n",
+"L1L2=L1*L2\n",
+"//PATH FACTORS\n",
+"D3=1;D4=1;D5=1;D6=1\n",
+"D1=1-L2\n",
+"D2=1-L1\n",
+"//GRAPH DETERMINANT\n",
+"D=1-(L1+L2+L3)+(L1L2);\n",
+"D=simple(D)\n",
+"disp(D,'graph_determinant=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_4: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.4\n",
+"//page 67\n",
+"syms G1 G2 G3 H1;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G2*1;\n",
+"P2=G1*G3;\n",
+"L1=G2*(-1);\n",
+"L2=G3*(-1);\n",
+"L3=-G1*G2*H1\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3);\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_5: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.5\n",
+"//page 68\n",
+"syms G1 G2 G3 H1 H2;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G2;\n",
+"P2=G1*G3;\n",
+"L1=-G2*H2;\n",
+"L2=-G1*G2*H1;\n",
+"L3=G1*G3*(-H2)*G2*(-H1);\n",
+"L3=simple(L3)\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_6: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.6\n",
+"//page 69\n",
+"syms G1 G2 G3 G4 H1 H2;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"// to find C/R consider D=0\n",
+"P1=G1*G3*G4;\n",
+"P2=G2*G3*G4;\n",
+"L1=-G3*H1;\n",
+"L2=-G1*G3*G4*H2;\n",
+"L3=-G2*G3*G4*H2;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_7: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.7\n",
+"//page 70\n",
+"syms G1 G2 G3 H1;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G3*G4;\n",
+"P2=G1*(-G2);\n",
+"L1=G3*G4*(-1);\n",
+"L2=G1*G3*H1*(-1);\n",
+"L3=G1*G3*H1*(-1);\n",
+"L4=G1*(-G2)*(-1)*G3*H1*(-1);\n",
+"L5=G1*(-G2)*(-1)*G3*H1*(-1);\n",
+"L4=simple(L4);\n",
+"L5=simple(L5);\n",
+"D1=1;\n",
+"D2=1;\n",
+"D=1-(L1+L2+L3+L4+L5);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_8: Transfer_function_using_mason_gain_formula.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_using_mason's_gain_formula\n",
+"// example 4.4.8\n",
+"//page 70\n",
+"syms G1 G2 G3 G4 G5 H1 H2;\n",
+"// forward path denoted by P1,P2 and so on and loop by L1,L2 and so on \n",
+"//path factor by D1,D2 and so on and graph determinant by D\n",
+"P1=G1*G2*G4;\n",
+"P2=G2*G3*G5;\n",
+"P3=G3;\n",
+"L1=-G4*H1;\n",
+"L2=-G2*G4*H2;\n",
+"L3=-G2*G5*H2;\n",
+"D1=1;\n",
+"D2=1;\n",
+"D3=1-L1;\n",
+"D=1-(L1+L2+L3);\n",
+"D=simple(D)\n",
+"Y=(P1*D1+P2*D2+P3*D3)/D;\n",
+"Y=simple(Y);\n",
+"disp(Y,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.4_9: Overall_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function\n",
+"// example 4.4.9\n",
+"//page 71\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"exec parallel.sce;\n",
+"exec series.sce;\n",
+"syms G1 G2 G3 G4 H5 H1 H2;\n",
+"//shift the SUMMING point locsted after G3 towards left of block G3\n",
+"a=G2/.H1;\n",
+"b=G5/G3;\n",
+"c=parallel(a,b);\n",
+"c=simple(c);\n",
+"d=G3/.H2;\n",
+"e=series(G1,c);\n",
+"f=series(e,d);\n",
+"y=series(G4,f);\n",
+"y=simple (y);\n",
+"disp(y,'C(s)/R(s)=')"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/5-MODELLING_A_CONTROL_SYSTEM.ipynb b/Linear_Control_Systems_by_B_S_Manke/5-MODELLING_A_CONTROL_SYSTEM.ipynb
new file mode 100644
index 0000000..4310824
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/5-MODELLING_A_CONTROL_SYSTEM.ipynb
@@ -0,0 +1,421 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 5: MODELLING A CONTROL SYSTEM"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_10: Overall_Transfer_Function_of_given_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_given_system\n",
+"//example 5.9.10\n",
+"//page 108\n",
+"syms Ra Kt Jm fm Kb\n",
+"//where Ra=armature_resistance; Kt=motor_torque_const; Jm=moment_of_inertia; fm=coeff_of_viscous_friction; Kb=motor_back_emf_const\n",
+"s=%s;\n",
+"a=Kt/(s*Ra*(s*Jm+fm));\n",
+"a=simple(a);\n",
+"b=s*Kb;\n",
+"c=a/(1+a*b);\n",
+"c=simple(c);\n",
+"disp(c,'Q(s)/V(s)=');//overall_transfer_function\n",
+"Kt=0.183;Kb=0.183;Ra=4.8;Jm=.004;fm=0.0015;\n",
+"a=Kt/(s*Ra*(s*Jm+fm));\n",
+"b=s*Kb;\n",
+"c=a/(1+a*b);\n",
+"disp(c,'Q(s)/V(s)=');//overall_transfer_function_after substituting value in above equation"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_11: Overall_Transfer_Function_of_given_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_positional_control_system\n",
+"//example 5.9.11\n",
+"//page 109\n",
+"syms Ka Ke Kb Kt Jeq feq Ra N1 N2\n",
+"//where Ka=amplifier_gain; Ke=error_detector_gain; Kb=motor_back_emf_const; Kt=motor_torque_const; Ra=armature_resistance; Jeq=moment_of_inertia; feq=coeff_of_viscous_friction; \n",
+"s=%s;\n",
+"Kt=.0001;Ra=0.2;Jeq=.0001;feq=.0005;Ka=10;Ke=2;Kb=0.0001;f=0.1;\n",
+"a=(Ka*Ke); // in series\n",
+"b=Kt/(s*Ra*(Jeq*s+feq));\n",
+"c=b/(1+b*s*Kb);\n",
+"d=(a*c); // in series\n",
+"f=0.1;\n",
+"g=(d*f); // in series\n",
+"h=g/(1+g);\n",
+"disp(h,'C(s)/R(s)=');//overall_transfer_function_after substituting value in above equation"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_12: Overall_Transfer_Function_of_given_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_given_system\n",
+"//example 5.9.12\n",
+"//page 111\n",
+"syms Ka Ke Kf Rf Lf Jeq feq N1 N2\n",
+"//where Ka=amplifier_gain; Ke=error_detector_gain; Kf=motor_torque_const; Rf=field_resistance; Lf=field_inductance Jeq=moment_of_inertia; feq=coeff_of_viscous_friction;\n",
+"s=%s;\n",
+"d=N1/N2;\n",
+"Ka=10; Ke=8; Kf=0.05; Rf=5; Lf=0.25; Jeq=0.05; feq=0.075; d=0.1;\n",
+"a=(Ka*Ke);\n",
+"b=Kf/(Rf+s*Lf);\n",
+"c=1/(s*(Jeq*s+feq));\n",
+"g=(b*c) //in series\n",
+"h=(g*a) //in series\n",
+"i=(h*d) //in series\n",
+"j=i/(1+i);\n",
+"disp(j,'C(s)/R(s)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_13: Overall_Transfer_Function_of_Two_Phase_ac_Motor.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_two_phase_ac_motor\n",
+"//example 5.9.13\n",
+"//page 113\n",
+"syms Ka K Ktg Jeq feq N1 N2 m\n",
+"//where Ka=amplifier_gain; Ktg=tachometer_gain_const Jeq=moment_of_inertia; feq=coeff_of_viscous_friction; \n",
+"s=%s;\n",
+"//from torque characterstics m and K are determined \n",
+"Ka=20; K=0.0012; Ktg=0.2; Jeq=0.00015; feq=0.0001;m=-0.0003;\n",
+"a=K/(Jeq*s+(feq-m));\n",
+"b=N1/N2;\n",
+"b=0.1;\n",
+"c=(Ka*a) // in series\n",
+"d=(c*b) // in series\n",
+"e=d/(1+Ktg*d);\n",
+"disp(e,'C(s)/R(s)=');//overall_transfer_function"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_14: Transfer_Function_Of_Motor.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_of_motor\n",
+"//example 5.9.14\n",
+"//page 114\n",
+"syms Kt Kb Ra La J \n",
+"//where Ka=amplifier_gain; Kt=motor_torque_const; Ra=armature_resistance; La=armature_inductor; J=moment_of_inertia \n",
+"s=%s;\n",
+"//since there are two inputs Va(s)and Tl(s).If Va(s) is held at fixed value then only effect of Tl(s) is considered and Va(s)is taken as Zero.\n",
+"a=(Kt*Kb)/(Ra+s*La)\n",
+"b=1/J*s\n",
+"c=b/(1+b*a);\n",
+"disp(-c,'Wm(s)/Tl(s)=');//negative sign indicates that an increase in Tl decreases Wm\n",
+"Kb=9.55;Kt=9.55;Ra=0.75;La=0.005;J=50;\n",
+"a=(Kt*Kb)/(Ra+s*La)\n",
+"b=1/(J)*(1/(s))\n",
+"c=b/(1+b*a);\n",
+"disp(-c,'Wm(s)/Tl(s)=');//after putting values"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_4: Calculate_Reference_Voltage_Vr.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_reference_voltage_Vr\n",
+"//example 5.9.4\n",
+"//page 102\n",
+"exec series.sce;\n",
+"A=2//amplifier\n",
+"K=10//motor_field\n",
+"N=100//speed\n",
+"tg=0.1//tacho_generator\n",
+"a=series(A,K);\n",
+"b=a/.tg;\n",
+"disp(b,'N/Vr=');\n",
+"//since N=100\n",
+"Vr=N*(1/b);\n",
+"disp(Vr,'reference_voltage=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_5: Calculate_Reference_Voltage_Vr.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_reference_voltage_Vr\n",
+"//example 5.9.5\n",
+"//page 102\n",
+"exec series.sce;\n",
+"Vt=250//output_voltage\n",
+"Rf=100//field_winding_resistance\n",
+"Kg=500//generator_constant\n",
+"A=2//amplifier\n",
+"Vf=0.4//fraction_of_output_voltage_compared_with_reference_voltage\n",
+"a=1/Rf;\n",
+"b=series(A,a);\n",
+"c=series(b,Kg);\n",
+"d=c/.Vf;\n",
+"disp(d,'Vt/Vr=');\n",
+"//since Vt=250\n",
+"Vr=Vt*(1/d);\n",
+"disp(Vr,'reference_voltage=');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_6: Calculate_Gain_of_Amplifier_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_gain_of_amplifier_Ka\n",
+"//example 5.9.6\n",
+"//page 103\n",
+"//steady state equations: Ei=Vt+Il*Ra and Vt=Il*Rl\n",
+"//where Vt=output_voltage, Rl=load_resistance, Ra=armature_resistance, Il=load_current, \n",
+"syms Rl Ra Ka Er e;\n",
+"Ei=450;\n",
+"If=1.5;//field current\n",
+"Kg=Ei/If;//generator_emf_constant\n",
+"Vt=400;\n",
+"//from stedy state eq. we get : Vt/Ei=Rl/(Rl+Ra)\n",
+"a=Rl/(Rl+Ra);\n",
+"a=Vt/Ei;\n",
+"c=(Kg*a);\n",
+"G=(Ka*c);\n",
+"H=0.1;\n",
+"//transfer function relating erroe 'e' and the reference voltage 'Er' is e/Er=1/(1+GH)\n",
+"b=e/Er;\n",
+"b=1/(1+G*H);\n",
+"e=Vt*H*.02 ;//since allowable error is 2% \n",
+"Er=(Vt*H)+e;\n",
+"//since e/Er=1/(1+G*H), on putting value of e,Er,G and H and solving we get\n",
+"Ka=1.89;\n",
+"disp(Ka,'gain_of_amplifier_Ka=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_7: Transfer_Function_of_Generator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:transfer_function_of_generator\n",
+"//example 5.9.7\n",
+"//page 105\n",
+"syms E Vf Kg R L\n",
+"s=%s;\n",
+"//generator_field_constant_Kg=delta(e)/delta(If)\n",
+"Kg=50/2;\n",
+"L=2;//field_inductance\n",
+"R=200;//field_resistance\n",
+"//transfer function is given by : E/Vf=(Kg/R+s*L)\n",
+"a=Kg/(R+s*L);\n",
+"disp(a,'E(s)/Vf(s)=');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_8: Overall_Transfer_Function_of_given_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_given_system\n",
+"//example 5.9.8\n",
+"//page 105\n",
+"syms Rf Ra Kb Jm Lf La Kg Kt Jl s\n",
+"Rf=1000;//field_resistance\n",
+"Lf=100;//field_inductanc\n",
+"Kg=1000;//generator_field_constant\n",
+"Ra=20;//armature_resistance\n",
+"La=0.1;//armature_inductance\n",
+"Kt=1.2;//motor_torque_const\n",
+"Kb=1.2;//motor_back_emf_const\n",
+"Jl=0.00003;//moment_of_inertia\n",
+"Jm=0.00002;//coeff_of_viscous_friction\n",
+"a=Kt/(Ra+s*La);\n",
+"b=1/((Jm+Jl)*s);\n",
+"c=(a*b);\n",
+"d=c/(1+c*Kb);\n",
+"e=Kg/(Rf+s*Lf);\n",
+"f=(d*e);\n",
+"f=simple(f)\n",
+"disp(f,'wss(s)/Vf(s)=');\n",
+"\n",
+"//steady state value\n",
+"disp('under steady state condition, on putting s=0 in expression f,we get:')\n",
+"disp('Vf=1.2*wss')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9_9: Overall_Transfer_Function_of_given_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_of_given_system\n",
+"//example 5.9.9\n",
+"//page 107\n",
+"syms Ka Ke Kt J f N1 N2\n",
+"s=%s;\n",
+"Ke=10;//error_detector_gain\n",
+"Ka=100;//amplifier_transconductance\n",
+"Kt=.0005;//motor_torque_const\n",
+"J=.0000125;//moment_of_inertia\n",
+"f=.0005;//coeff_of_viscous_friction\n",
+"g=N1/N2;\n",
+"g=1/20;\n",
+"a=(Ka*Ke);\n",
+"b=(a*Kt);\n",
+"c=1/(J*s^2+f*s);\n",
+"d=(c*b);\n",
+"e=(g*d);\n",
+"h=e/(1+e);\n",
+"disp(h,'C(s)/R(s)=');//result"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/6-TIME_RESPONSE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb b/Linear_Control_Systems_by_B_S_Manke/6-TIME_RESPONSE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
new file mode 100644
index 0000000..d5c2afc
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/6-TIME_RESPONSE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
@@ -0,0 +1,1060 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 6: TIME RESPONSE ANALYSIS OF CONTROL SYSTEMS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_10: Determine_Transfer_Function_Wn_zeta.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_function,Wn,zeta\n",
+"//example 6.10.10\n",
+"//page 179\n",
+"//J=moment of inertia,f=C,Ke=error detector gain,Wn=natural frequency, zeta=damping ratio,Km=torque constant\n",
+"syms J f s\n",
+"Ke=5.73;\n",
+"Km=0.045;\n",
+"n=sym('N1/N2')\n",
+"n=subs(n,'N1/N2',1/10);\n",
+"J=0.25*float(n^2);//referred to motor side\n",
+"f=1*float(n^2);//referred to motor side\n",
+"//from the block diagram given in fig 6.10.6 on page 179,\n",
+"a=(Ke*Km)\n",
+"b=1/(J*s^2+f*s)\n",
+"c=(b*float(a))\n",
+"G=(n*c);\n",
+"G=simple(G)\n",
+"H=1;\n",
+"d=(1+G*H);\n",
+"d=simple(d);\n",
+"CL=G/d;\n",
+"CL=simple(CL)\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"e=poly([328800 127516 31879],'s','coeff')\n",
+"printf('the characterstics eq. is:\n');\n",
+"disp(e);\n",
+"f=coeff(e)\n",
+"Wn=sqrt((f(1,1)/f(1,3)))//natural_frequency\n",
+"zeta=((f(1,2)/f(1,3))/(2*Wn))//damping ratio\n",
+"//part(b)\n",
+"syms Td\n",
+"g=1+s*Td\n",
+"h=(g*G)\n",
+"i=1+h*H\n",
+"i=simple(i);\n",
+"CL2=(h/i)\n",
+"CL2=simple(CL2);\n",
+"disp(CL2,'C(s)/R(s)=');\n",
+"poly(0,'s');\n",
+"l=s^2+(10.32*Td+4)*s+10.32;\n",
+"printf('on simplyfying the characterstics eq. is:');\n",
+"disp(float(l));\n",
+"Wn1=sqrt(10.32)//natural_frequency\n",
+"//2*zeta1*Wn1=10.32*Td+4\n",
+"zeta1=1;//as damping is critical\n",
+"Td=(2*zeta1*Wn1-4)/10.32;\n",
+"disp(Td,'time const. of advanced phase circuit,Td=');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_11: Determine_Characterstics_eq_and_Steady_State_Error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_characterstics_eq_and_steady_state_error\n",
+"//example 6.10.11\n",
+"//page 181\n",
+"//J=moment of inertia,f=C,K=controller gain,Wn=natural frequency, zeta=damping ratio\n",
+"syms f J K Kt\n",
+"s=%s;\n",
+"A=sym((1/(J*s^2+f*s)));\n",
+"J=250;\n",
+"K=8*10^4;\n",
+"B=eval(A)\n",
+"a=(K*B);\n",
+"H1=s*Kt;\n",
+"b=(1+a*H1);\n",
+"b=simple(b);\n",
+"CL1=a/b;\n",
+"CL1=simple(CL1);\n",
+"H=1;\n",
+"c=1+CL1*H;\n",
+"c=simple(c);\n",
+"CL=CL1/c\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"Wn=sqrt(80000/250)//natural frequency\n",
+"//2*zeta*Wn=(80000*Kt+f)/250\n",
+"zeta=1;//for critical damping\n",
+"d=2*zeta*Wn;\n",
+"v=[320 d 1];\n",
+"CH=poly(v,'s','coeff');\n",
+"r=float(5*2*%pi/60);\n",
+"//steady state error for unit ramp input is:Ess= (2*zeta/Wn)\n",
+"Ess=(2*zeta/Wn)*r;\n",
+"disp(Ess,'steady_state_error=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_12: determine_WnWd_zeta_and_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,Wd,zeta_and_steady_state_error\n",
+"//example 6.10.12\n",
+"//page 182\n",
+"clc;\n",
+"s=%s;\n",
+"G=sym('25/(s*(s+5))');\n",
+"G=simple(G);\n",
+"H=1;\n",
+"CL=G/.H;\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"printf('the char. eq is:')\n",
+"disp('s^2+5*s+25')\n",
+"Wn=sqrt(25)//natural_frequency\n",
+"//2*zeta*Wn=5\n",
+"zeta=5/(2*Wn);//damping ratio\n",
+"d=zeta*Wn;//damping_factor\n",
+"z=sqrt(1-zeta^2);\n",
+"Wd=Wn*z;//damped_frequency_of_oscillation\n",
+"Mp=exp((-zeta*%pi)/z)*100;//%_max.peak_overshoot\n",
+"//steady state error for unit ramp input is:Ess= (2*zeta/Wn)\n",
+"Ess=(2*zeta/Wn);//steady state error\n",
+"disp('part(a):')\n",
+"disp(Wn,'natural_frequency,Wn=');\n",
+"disp(zeta,'damping ratio,zeta=');\n",
+"disp(Wd,'damped_frequency_of_oscillation,Wd=');\n",
+"disp(Mp,'%_max.peak_overshoot,Mp=');\n",
+"disp(Ess,'steady state error,Ess=');\n",
+"//if damping ratio is increased from 0.5 to 0.75 by incorporating tachometer feedback\n",
+"zeta=0.75;\n",
+"H1=sym('s*Kt')//tachometer_feedback\n",
+"CL1=G/(1+G*H1);\n",
+"CL1=simple(CL1);\n",
+"CL2=CL1/(1+H*CL1);\n",
+"CL2=simple(CL2);\n",
+"disp(CL2,'C(s)/R(s)=');\n",
+"Wn=sqrt(25);\n",
+"//2*zeta*Wn=25*Kt+5;\n",
+"Kt=(2*zeta*Wn-5)/25;//tachometer_gain\n",
+"Mp1=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"disp('After applying tachometer feedback:')\n",
+"disp(Kt,'tachometer_gain,Kt=');\n",
+"disp(Mp1,'%_peak_overshoot,Mp1=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_13: determine_K_ts_tp_and_Mp.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_K,ts,tp,Mp\n",
+"//example 6.10.13\n",
+"//page 184\n",
+"clc;\n",
+"syms K;\n",
+"s=%s;\n",
+"G=sym('K/(s*(s+6))');\n",
+"H=0.2;\n",
+"CL=G/(1+G*H);\n",
+"CL=simple(CL);\n",
+"Wn=sqrt(K/5)\n",
+"zeta=0.7//(given) damping ratio\n",
+"//2*zeta*Wn=6\n",
+"Wn=6/(2*zeta);\n",
+"K=Wn^2*5;\n",
+"ts=4/(zeta*Wn);//settling_time\n",
+"Mp=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"tp=%pi/(Wn*sqrt(1-zeta^2));//peak_time\n",
+"disp(Wn,'natural_frequency,Wn=');\n",
+"disp(Mp,'%_max.peak_overshoot,Mp=');\n",
+"disp(ts,'settling_time,ts=');\n",
+"disp(tp,'peak_time,tp=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_14: determine_Mp_Ess_and_steady_state_value.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Mp,Ess_and_steady_state_value\n",
+"//example 6.10.14\n",
+"//page 185\n",
+"//there are two inputs: R(s) is reference input and Tl(s)is load torque\n",
+"clc;\n",
+"s=%s;\n",
+"A=sym('1/(0.15*s^2+0.9*s)');\n",
+"K=6;\n",
+"//while considering R(s),we take Tl(s)=0\n",
+"G=(A*K); //in series\n",
+"H=1;\n",
+"CL=G/(1+G*H);\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"Wn=sqrt(40);//natural_frequency\n",
+"//2*zeta*Wn=6\n",
+"zeta=6/(2*Wn);//damping ratio\n",
+"Mp=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"//steady state error for unit ramp input is:Ess= (2*zeta/Wn)\n",
+"Ess=(2*zeta/Wn);//steady state error\n",
+"disp(Mp,'%_peak_overshoot=');\n",
+"disp(Ess,'steady state error=');\n",
+"printf('Now considering effect of Tl(s),put R(s)=0\n');\n",
+"H=6;\n",
+"CL1=A/(1+A*H);\n",
+"CL1=simple(CL1);\n",
+"disp(CL1,'C(s)/-Tl(s)=');//-ve sign indicates output position lags behind the input\n",
+"Tl=1/s;//given\n",
+"C=-Tl*CL1;\n",
+"Css=limit(s*C,s,0);\n",
+"disp(Css,'steady state value of output=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_16: determine_Wn_zeta_and_M.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Wn,zeta_and_Mp\n",
+"//example 6.10.16\n",
+"//page 187\n",
+"s=%s;\n",
+"num=1;\n",
+"den=sym('s*(1+0.5*s)*(1+0.2*s)');\n",
+"c=num/den;\n",
+"c=simple(c);\n",
+"disp(c,'C(s)/E(s)=');\n",
+"G=c;\n",
+"H=1;\n",
+"CL=G/(1+G*H);\n",
+"CL=simple(CL);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"A=pfss((10/(s^3+7*s^2+10*s+10)));\n",
+"d=denom(A(1));\n",
+"b=coeff(denom(A(1)))\n",
+"printf('for oscillatory roots:')\n",
+"Wn=sqrt(b(1,1));//natural_frequency\n",
+"//2*zeta*Wn=1.5;\n",
+"zeta=1.5/(2*Wn);//damping ratio\n",
+"Mp=exp((-zeta*%pi)/sqrt(1-zeta^2))*100;//%_peak_overshoot\n",
+"disp(Wn,'natural_frequency=');\n",
+"disp(zeta,'damping ratio=');\n",
+"disp(Mp,'%_peak_overshoot=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_17: determine_Kp_Kv_and_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Kp_Kv_Ka\n",
+"//example 6.10.17\n",
+"//page 188\n",
+"s=%s;\n",
+"syms t;\n",
+"num=sym('2*(s^2+3*s+20)');\n",
+"den=sym('s*(s+2)*(s^2+4*s+10)');\n",
+"GH=num/den;\n",
+"GH=simple(GH);\n",
+"disp(GH,'G(s)H(s)=');\n",
+"input1=5;\n",
+"Kp=limit(GH,s,0);//static positional error coefficient\n",
+"Ess=5*(1/(1+Kp));//steady state error\n",
+"e=(1/(%inf+1));\n",
+"e=0;\n",
+"Ess=e;\n",
+"disp(Kp,'static positional error coefficient=');\n",
+"disp(Ess,'steady state error=');\n",
+"input2=4*t;\n",
+"Kv=limit(s*GH,s,0);//static velocity error coefficient\n",
+"Ess=(1/Kv)*4;//steady state error\n",
+"disp(Kv,'static velocity error coefficient=');\n",
+"disp(Ess,'steady state error=');\n",
+"input3=(4*t^2)/2;\n",
+"Ka=limit(s^2*GH,s,0);//static acceleration error coefficient\n",
+"Ess=(1/Ka)*4;//steady state error\n",
+"disp(Ka,'static acceleration error coefficient=');\n",
+"disp('steady state error=');\n",
+"disp('infinity')\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_18: determine_Kp_Kv_and_Ka.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_Kp_Kv_Ka\n",
+"//example 6.10.17\n",
+"//page 188\n",
+"s=%s;\n",
+"syms t K zeta Wn;\n",
+"num=K;\n",
+"den=sym('s*(s^2+2*zeta*Wn*s+Wn^2)');\n",
+"G=num/den;\n",
+"G=simple(G);\n",
+"disp(G,'G(s)=');\n",
+"Kp=limit(G,s,0);//static positional error coefficient\n",
+"disp(Kp,'static positional error coefficient,Kp=');\n",
+"Kv=limit(s*G,s,0);//static velocity error coefficient\n",
+"disp(Kv,'static velocity error coefficient,Kv=');\n",
+"Ka=limit(s^2*G,s,0);//static acceleration error coefficient\n",
+"disp(Ka,'static acceleration error coefficient,Ka=');\n",
+"printf('for(ii):');\n",
+"num=sym('100*(s+2)*(s+40)');\n",
+"den=sym('s^3*(s^2+4*s+200)');\n",
+"GH=num/den;\n",
+"GH=simple(GH);\n",
+"disp(GH,'G(s)H(s)=');\n",
+"Kp=limit(GH,s,0);//static positional error coefficient\n",
+"disp(Kp,'static positional error coefficient,Kp=');\n",
+"Kv=limit(s*GH,s,0);//static velocity error coefficient\n",
+"disp(Kv,'static velocity error coefficient,Kv=');\n",
+"Ka=limit(s^2*GH,s,0);//static acceleration error coefficient\n",
+"disp(Ka,'static acceleration error coefficient,Ka=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_19: determine_steady_state_error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_steady_state_error\n",
+"//example 6.10.19\n",
+"//page 189\n",
+"s=%s;\n",
+"syms K bta alpha G\n",
+"num=sym('K*s+bta');\n",
+"den=sym('s^2+alpha*s+bta');\n",
+"CL=num/den;\n",
+"disp(CL,'C(s)/R(s)=');//----(1)\n",
+"H=1;\n",
+"//also\n",
+"cl=G/(1+G*H);\n",
+"disp(cl,'also,C(s)/R(s)=');//------(2)\n",
+"//from eq. (1) and (2), we get\n",
+"G=num/(s^2+s*(alpha-K));\n",
+"disp(G,'G(s)=');\n",
+"B=1/(1+G);\n",
+"B=simple(B);\n",
+"disp(B,'E(s)/R(s)=');\n",
+"R=1/s^2;\n",
+"E=B*R;\n",
+"E=simple(E);\n",
+"Ess=limit(s*E,s,0);\n",
+"disp(Ess,'steady state error=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_1: time_response_for_step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_step_function\n",
+"//example 6.10.1\n",
+"//page 170\n",
+"// we have defined parallel and series function which we are going to use here\n",
+"exec parallel.sce;\n",
+"exec series.sce;\n",
+"s=%s;\n",
+"syms t;\n",
+"a=4/(s*(s+4))\n",
+"b=s+1.2\n",
+"c=s+0.8\n",
+"d=a/(1+a)\n",
+"e=parallel(b,c)\n",
+"f=d/.e;\n",
+"disp(f,'C(s)/R(s)=');//transfer function\n",
+"//since input:r(t)=2, so R(s)=2/s;//step_function_of_magnitude_2\n",
+"g=f*(2/s);\n",
+"disp(g,'C(s)=');\n",
+"[A]=pfss(8/(s*(s+2)*(s+6)))\n",
+"F=ilaplace((8/(s*(s+2)*(s+6))),s,t);\n",
+"disp(F,'time_response_for_step_function_of_magnitude_2,f(t)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_20: determine_steady_state_error_and_error_coefficient.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_steady_state_error_and_error_coefficient\n",
+"//example 6.10.20\n",
+"//page 189\n",
+"s=%s;\n",
+"syms t a0 a1 a2;\n",
+"r=a0+a1*t+(a2/2)*t^2;\n",
+"//since for 'r' only upto 2nd order derivative is non zero, so only coeff. C0 C1 C2 exist\n",
+"num=20;\n",
+"den=sym('(s*(s+2))');\n",
+"G=num/den;\n",
+"disp(G,'G(s)=');\n",
+"A=1/(1+G);\n",
+"A=simple(A);\n",
+"disp(A,'E(s)/R(s)=');\n",
+"C0=limit(A,s,0);\n",
+"B=sym('((20)/(s^2+2*s+20))');//on simplyfying A=1-B\n",
+"d=diff(-B,s);\n",
+"C1=limit(d,s,0);\n",
+"d1=diff(-B,s,2);\n",
+"C2=limit(d1,s,0);\n",
+"r1=diff(r,t);\n",
+"r2=diff(r,t,2);\n",
+"e=(C0*r)+(C1*r1)+(C2*r2)/2;\n",
+"disp(C0,'C0=');\n",
+"disp(float(C1),'C1=');\n",
+"disp(float(C2),'C2=');\n",
+"disp(float(e),'steady_state_error,e=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_21: determine_steady_state_error_and_error_coefficient.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_steady_state_error_and_error_coefficient\n",
+"//example 6.10.21\n",
+"//page 191\n",
+"s=%s;\n",
+"syms t;\n",
+"r=2+3*t+2*t^3;\n",
+"//since for 'r' only upto 2nd order derivative is non zero, so only coeff. C0 C1 C2 exist\n",
+"G=sym('1/(s*(s+2))');\n",
+"A=1/(1+G);\n",
+"A=simple(A);\n",
+"disp(A,'E(s)/R(s)=');\n",
+"C0=limit(A,s,0);\n",
+"B=sym('((1)/(s^2+2*s+1))');//on simplyfying A=1-B\n",
+"d=diff(-B,s);\n",
+"C1=limit(d,s,0);\n",
+"d1=diff(-B,s,2);\n",
+"C2=limit(d1,s,0);\n",
+"r1=diff(r,t);\n",
+"r2=diff(r,t,2);\n",
+"d2=diff(-B,s,3)\n",
+"C3=limit(d2,s,0)\n",
+"e=(C0*r)+(C1*r1)+(C2*r2)/2;\n",
+"disp(float(e),'steady_state_error,e=');\n",
+"disp(C0,'C0=');\n",
+"disp(float(C1),'C1=');\n",
+"disp(float(C2),'C2=');\n",
+"disp(float(C3),'C3=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_22: determine_voltage_Er_and_change_in_terminalvoltage.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_reference_voltage,Er_and_%change_in_terminal_voltage\n",
+"//example 6.10.22\n",
+"//page 191\n",
+"clc;\n",
+"syms G H \n",
+"s=%s;\n",
+"A=G/.H;\n",
+"disp(A,'E0/Er=');\n",
+"G=200; //gain\n",
+"H=0.1;\n",
+"B=eval(A);\n",
+"disp(B,'E0/Er=');\n",
+"E0=250;\n",
+"Er=(1/B)*E0;\n",
+"disp('for_closed_loop_system:');\n",
+"disp(float(Er),'reference_voltage,Er=');\n",
+"disp('for_open_loop_system:');\n",
+"disp(float(E0/G),'Er=E0/G=');\n",
+"\n",
+"disp('part (b)')\n",
+"disp('for closed loop system:')\n",
+"disp('as the forward path gain is reduced by 10%, the new value of gain,G is 180 ')\n",
+"G=180 //gain\n",
+"pcG=10 //percentage change in G\n",
+"S=1/(1+G*H)\n",
+"disp(S,'sensitivity,S=');\n",
+"disp('since S=1/19, (given)')\n",
+"pcM=S*pcG //percentage change in overall gain,M\n",
+"pcEo=pcM\n",
+"disp(pcM,'percentage change in overall gain,M=')\n",
+"disp(pcEo,'percentage change in terminal voltage,Eo=')\n",
+"disp('for open loop system:')\n",
+"pcEo=(25/250)*100 \n",
+"disp(pcEo,'percentage change in terminal voltage,Eo=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_23: determine_sensitivity_wrt_K_and_H.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_sensitivity_w.r.t_K_and_H\n",
+"//example 6.10.23\n",
+"//page 192\n",
+"syms Wn zeta K H;\n",
+"s=%s;\n",
+"A=sym('Wn^2/(s^2+2*zeta*Wn*s)');\n",
+"B=(A*K);\n",
+"CL=B/(1+B*H);\n",
+"CL=simple(CL);\n",
+"disp(CL,'overall_transfer_function:M(s)=');\n",
+"disp('sensitivity_w.r.t_K:');\n",
+"a=diff(CL,K);\n",
+"b=K/CL;\n",
+"b=simple(b);\n",
+"Sk=a*b;\n",
+"Sk=simple(Sk);\n",
+"disp(Sk,'sensitivity_w.r.t_K,Sk=');\n",
+"disp('sensitivity_w.r.t_H:');\n",
+"c=diff(CL,H);\n",
+"d=H/CL;\n",
+"d=simple(d);\n",
+"Sh=c*d;\n",
+"Sh=simple(Sh);\n",
+"disp(Sh,'sensitivity_w.r.t_H,Sh=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_2: Time_Response_for_unit_Impulse_and_Step_function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_impulse_and_step_function\n",
+"//example 6.10.2\n",
+"//page 171\n",
+"//G(s)=(4*s+1)/4*(s^2);H(s)=1;\n",
+"clc;\n",
+"s=%s;\n",
+"syms t;\n",
+"G=(4*s+1)/(4*(s^2))//G(s)\n",
+"b=1;\n",
+"a=G/.(b);\n",
+"disp(a,'C(s)/R(s)=');\n",
+"//for unit impulse response R(s)=1 ; so C(s)=a;\n",
+"disp('for unit impulse response R(s)=1 ; so C(s)=a;')\n",
+"disp(a,'C(s)=');\n",
+"c=ilaplace(a,s,t);\n",
+"disp(c,'c(t)=');\n",
+"//for unit step response R(s)=1/s\n",
+"disp('for unit step response R(s)=1/s, so'); \n",
+"d=a*(1/s);\n",
+"disp(d,'C(s)=');\n",
+"e=ilaplace(d,s,t);\n",
+"disp(e,'c(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_3: Time_Response_for_Unit_Step_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 6.10.3\n",
+"//page 172\n",
+"//G(s)=2/(s*(s+3)\n",
+"clc;\n",
+"s=%s;\n",
+"syms t;\n",
+"G=2/(s*(s+3))//G(s)\n",
+"b=1;\n",
+"a=G/.(b);\n",
+"disp(a,'C(s)/R(s)=');\n",
+"disp('for unit step response R(s)=1/s'); \n",
+"d=a*(1/s);\n",
+"disp(d,'C(s)=');\n",
+"e=ilaplace(d,s,t);\n",
+"disp(e,'c(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_4: Time_Response_for_Unit_Step_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response_for_unit_step_function\n",
+"//example 6.10.4\n",
+"//page 172\n",
+"s=%s;\n",
+"syms t;\n",
+"a=(s+4);\n",
+"b=1/(s*(s+2));\n",
+"c=(a*b); //in series\n",
+"d=0.5;\n",
+"e=c/.d\n",
+"f=1;\n",
+"g=e/.f;\n",
+"disp(g,'C(s)/R(s)=');\n",
+"disp('for unit step response R(s)=1/s, so'); \n",
+"h=g*(1/s);\n",
+"disp(h,'C(s)=');\n",
+"[A]=pfss(h);\n",
+"A(1)=(1/s)\n",
+"F1=ilaplace(A(1),s,t)\n",
+"//A(2)can be written as: A(2)=a1+a2\n",
+"a1=-1/(4*(6+3.5*s+s^2));\n",
+"a2=(-(s+1.75)/(6+3.5*s+s^2)); \n",
+"F2=ilaplace(a1,s,t);\n",
+"F3=ilaplace(a2,s,t);\n",
+"//now multiplying by their coefficient\n",
+"F1=(2/3)*F1;\n",
+"F2=(1/6)*F2;\n",
+"F3=(2/3)*F3;\n",
+"//after adding F1,F2 and F3 and simplyfying we get time response which is denoted by 'c(t)' \n",
+"disp('c(t)=((2-(%e^(-1.75*t)*(2*cos(1.71*t)-0.29*sin(1.71*t))))/3');//time_response"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_5: Calculate_Wn_zeta_Wd_tp_Mp.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:calculate_Wn,zeta,Wd,tp,Mp\n",
+"//example 6.10.5\n",
+"//page 174\n",
+"//given G(s)=20/(s+1)*(s+2)\n",
+"clc;\n",
+"s=%s;\n",
+"G=syslin('c',[20/((s+1)*(s+5))])//G(s):transfer function in forward path\n",
+"H=1;//backward path transfer function\n",
+"a=G/.H //closed loop transfer function\n",
+"b=denom(a)\n",
+"c=coeff(b)\n",
+"//Wn^2=c(1,1)\n",
+"Wn=sqrt(c(1,1))//natural frequency\n",
+"disp(Wn,'natural frequency,Wn=')\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=c(1,2)/(2*Wn)//damping ratio\n",
+"disp(zeta,'damping ratio,zeta=')\n",
+"Wd=Wn*sqrt(1-zeta^2)//damped frequency\n",
+"disp(Wd,'damping ratio,Wd=')\n",
+"Tp=%pi/Wd//peak time\n",
+"disp(Tp,'peak time,Tp=')\n",
+"Mp=(exp(-(zeta*%pi)/sqrt(1-zeta^2)))*100//max. overshoot\n",
+"disp(Mp,'max overshoot,Mp=')\n",
+"t=(2*%pi)/(Wn*sqrt(1-zeta^2))//period of oscillation\n",
+"disp(t,'time at which first overshoot occurs=')\n",
+"disp(t,'period of oscillation,t=')\n",
+"ts=4/(zeta*Wn)//settling time\n",
+"disp(ts,'settling time,ts=')\n",
+"N=Wd/(2*%pi)*ts//no. of oscillations completed before reaching steady state\n",
+"disp(N,'no. of oscillations completed before reaching steady state,N=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_6: Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:time_response\n",
+"//example 6.10.6\n",
+"//page 174\n",
+"//Kt=torque constant,J=moment of inertia,f=coeff. of viscous friction\n",
+"clc;\n",
+"syms Kt J f t\n",
+"s=%s;\n",
+"Kt=360,J=10,f=60\n",
+"b=1/(J*s^2+f*s);\n",
+"G=(Kt*b) //in series\n",
+"H=1;//backward path transfer function\n",
+"cl=G/.H;//closed_loop_transfer_function\n",
+"d=denom(cl)/10;//taking 10 common from numerator and denominator for simplyfying closed_loop_transfer_function\n",
+"f=numer(cl)/10;\n",
+"CL=f/d;//closed_loop_transfer_function_after_simplifying\n",
+"printf('overall transfer function= \n');\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"//given R(s)=(50*(%pi/180))*(1/s);\n",
+"R=(50*(%pi/180))*(1/s);\n",
+"C=R*CL;\n",
+"e=coeff(d)\n",
+"//Wn^2=e(1,1)\n",
+"Wn=sqrt(e(1,1))//natural frequency\n",
+"//2*zeta*Wn=c(1,2)\n",
+"zeta=e(1,2)/(2*Wn)//damping ratio\n",
+"//c(t):time_response_expression\n",
+"c=(5*%pi/18)*(1-(exp(-zeta*Wn*t)*sin(Wn*sqrt(1-zeta^2)*t+atan(sqrt(1-zeta^2)/zeta)))/sqrt(1-zeta^2));\n",
+"c=float(c)\n",
+"disp(c,'c(t)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_7: determine_factor_by_which_K_should_be_reduced.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_factor_by_which_K_should_be_reduced\n",
+"//example 6.10.7\n",
+"//page 175\n",
+"syms T K //K=forward_path_gain,T=time_constant\n",
+"s=%s;\n",
+"G=K/(s*(s*T+1));\n",
+"G=simple(G);\n",
+"printf('the_forward_path_transfer_function: \n' );\n",
+"disp(G,'G(s)=');\n",
+"H=1;//backward path transfer function\n",
+"CL=G/.H;\n",
+"CL=simple(CL);\n",
+"printf('the_overlall_transfer_function: \n' );\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"printf('the_characterstic_equation_is:\n ');\n",
+"disp('s^2+s/T+K/T=0');\n",
+"//from char. eq. we get Wn^2=K/T and 2*zeta*Wn=1/T, so\n",
+"Wn=sqrt(K/T);//natural frequency\n",
+"zeta=(1/2)*sqrt(1/K*T)\n",
+"//let K1 be forward path gain when Mp1=60% and zeta1 be corresponding damping factor\n",
+"syms K1 K2 zeta1 zeta2\n",
+"Mp1=(exp(-(zeta1*%pi)/sqrt(1-zeta1^2)))*100//max. overshoot\n",
+"//on solving we get :\n",
+"zeta1=0.158\n",
+"//similarly let K2 be forward path gain when Mp2=20% and zeta2 be corresponding damping factor, which gives\n",
+"zeta2=0.447\n",
+"//assuming time const. T to be const. we get\n",
+"k=(K1/K2);\n",
+"k=(zeta1/zeta2)^2;\n",
+"disp(k,'K1/K2=');\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_8: Determine_Steady_State_Speed_and_Error.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_steady_state_speed_and_error\n",
+"//example 6.10.8\n",
+"//page 176\n",
+"//Tm=torque constant,J=moment of inertia,f=coeff. of viscous friction, E=error detector gain\n",
+"syms Tm J f t E s\n",
+"Tm=75;J=10;f=5;E=1;\n",
+"a=(Tm*E);\n",
+"b=1/(J*s+f);\n",
+"c=(a*b);\n",
+"H=1;//backward path transfer function\n",
+"CL=c/.H;\n",
+"printf('the_overlall_transfer_function: \n' );\n",
+"disp(CL,'Wo(s)/Wr(s)=');\n",
+"//since Wr(s)=(2*%pi)*(1/s)\n",
+"q=bfloat((2*%pi),2)\n",
+"Wr=q*(1/s)\n",
+"Wo=CL*Wr;\n",
+"wo=ilaplace(Wo,s,t)\n",
+"printf('expression_relating_load_speed_and_time:\n');\n",
+"disp(wo,'wo(t)=');\n",
+"a=Wo*s\n",
+"Woss=limit(a,s,0);//steady state speed\n",
+"Woss=dbl(Woss);\n",
+"disp(Woss,'steady state speed=');\n",
+"We=Wr*(10*s+5)/(10*s+80);\n",
+"Wess=limit(s*We,s,0);//steady state error\n",
+"Wess=dbl(Wess);\n",
+"disp(Wess,'steady state error=');\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10_9: determine_J_f_K.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_J,f,K\n",
+"//example 6.10.9\n",
+"//page 178\n",
+"//J=moment of inertia,f=C,K=forward path gain,Wn=natural frequency, zeta=damping ratio\n",
+"syms J f K s zeta Wn\n",
+"CL=1/(J*s^2+f*s+K);\n",
+"printf('given:transfer function is:\n');\n",
+"disp(CL,'theta(s)/T(s)=');\n",
+"T=10*(1/s);\n",
+"theta=T*CL;\n",
+"theta_ss=limit(s*theta,s,0)//steady_state_value\n",
+"printf('given:theta_ss=0.5\n so K=10/0.5');\n",
+"theta_ss=0.5;\n",
+"K=10/theta_ss;\n",
+"disp(K,'forward path gain,K=');\n",
+"Mp=0.06;//max.peak overshoot (given)--------(1)\n",
+"Mp=exp((-zeta*%pi)/sqrt(1-zeta^2))//---------(2)\n",
+"//from eq. (1) and (2), we get\n",
+"zeta=0.66;\n",
+"tp=%pi/(Wn*(sqrt(1-zeta^2)));//-------(3)\n",
+"tp=1//(given)\n",
+"Wn=%pi/(tp*sqrt(1-zeta^2));\n",
+"//also Wn=sqrt(K/J);\n",
+"J=K/Wn^2;\n",
+"//also 2*zeta*Wn=f/J\n",
+"f=J*2*zeta*Wn;\n",
+"disp(J,'moment of inertia,J=');\n",
+"disp(f,'moment of inertia,f=');"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/7-STABILITY_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb b/Linear_Control_Systems_by_B_S_Manke/7-STABILITY_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
new file mode 100644
index 0000000..0c494a6
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/7-STABILITY_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
@@ -0,0 +1,1520 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 7: STABILITY ANALYSIS OF CONTROL SYSTEMS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1.0: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 1\n",
+"//page 291\n",
+"s=%s;\n",
+"g=s/(s+1);\n",
+"G=syslin('c',g)\n",
+"evans(g,200)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2.0: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 2\n",
+"//page 291\n",
+"s=%s;\n",
+"g=1/(s*(s+4));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.0: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 3\n",
+"//page 292\n",
+"s=%s;\n",
+"g=1/(s*(s+1)*(s+3));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_18: gain_phase_plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:gain_phase_plot\n",
+"//example 7.17.18\n",
+"//page 256\n",
+"k=1; \n",
+"s=%s; \n",
+"G=syslin('c',k/(s*(0.5*s+1)*(0.25*s+1))); \n",
+"// freq range to plot \n",
+"fmin=0.1; \n",
+"fmax=7; \n",
+"black(G, fmin, fmax) \n",
+"xgrid \n",
+"xtitle('Gain phase plot')\n",
+"disp('for GM=8 db, K=2.23') \n",
+"disp('for PM=20 deg. , K=2.69')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_1: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 7.17.1\n",
+"//page 236\n",
+"clf;\n",
+"s=%s;\n",
+"s1=-s;\n",
+"g=50/((s+1)*(s+2));\n",
+"g1=50/((s1+1)*(s1+2));\n",
+"GH=syslin('c',g)\n",
+"GH1=syslin('c',g1)\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-5 30 -20 20]);\n",
+"xtitle('Nyquist plot of 50/((s+1)*(s+2))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is not encircled by Nyquist plot ,so N=0 and P=0(given)')\n",
+"N=0;//no. of encirclement of -1+%i0 by G(s)H(s) plot\n",
+"P=0;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_2_ii: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 7.17.2_ii\n",
+"//page 237\n",
+"disp('for K=2.5')\n",
+"g=(2.5*(s+1))/((s+0.5)*(s-2));\n",
+"g1=(2.5*(s1+1))/((s1+0.5)*(s1-2));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-3 0.5 -0.6 0.6]);\n",
+"xtitle('Nyquist plot of (2.5*(s+1))/((s+0.5)*(s-2))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is encircled anticlockwise by Nyquist plot ,so N=1 and P=1(given)')\n",
+"N=1;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=1;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=0,there are no roots of closed loop characterstics eq having positive real part, hence system is stable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_2_i: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 7.17.2\n",
+"//page 237\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=1.25')\n",
+"g=(1.25*(s+1))/((s+0.5)*(s-2));\n",
+"g1=(1.25*(s1+1))/((s1+0.5)*(s1-2));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-1.5 0.2 -0.3 0.3]);\n",
+"xtitle('Nyquist plot of (10*(s-1))/((s+2)*(s+3));')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is encircled clockwise by Nyquist plot ,so N=-1 and P=1(given)')\n",
+"N=-1;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=1;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=2,there are two roots of closed loop characterstics eq having positive real part, hence system is unstable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_3: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 7.17.3\n",
+"//page 238\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"g=(s+0.25)/(s^2*(s+0.5)*(s+1));\n",
+"g1=(s1+0.25)/(s1^2*(s1+0.5)*(s1+1));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-2000 500 -30 30]);\n",
+"xtitle('Nyquist plot of (s+0.25)/(s^2*(s+0.5)*(s+1))')\n",
+"figure;\n",
+"show_margins(GH,'nyquist')\n",
+"disp('since the point(-1+%i0) is encircled clockwise by Nyquist plot ,so N=-1 and P=1(given)')\n",
+"N=-1;//no. of encirclement of -1+%i0 by G(s)H(s) plot anticlockwise\n",
+"P=1;//no. of poles of G(s)H(s) with positive real part\n",
+"Z=P-N;//np.of zeros of 1+G(s)H(s)=0 with positive real part\n",
+"disp(Z,'Z=')\n",
+"disp('as Z=2,there are two roots of closed loop characterstics eq having positive real part, hence system is unstable.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_5: Phase_Margi.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:phase_margin\n",
+"//example 7.17.5\n",
+"//page 241\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"disp('for K=3')\n",
+"g=(2.5*3)/(s*(0.4*s+1)*(0.2*s+1));\n",
+"g1=(2.5*3)/(s1*(0.4*s1+1)*(0.2*s1+1));\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-5 1 -500 500]);\n",
+"xtitle('Nyquist plot of (2.5*3)/(s*(0.4*s+1)*(0.2*s+1))')\n",
+"pm=p_margin(GH)\n",
+"disp(pm,'phase margin=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_7: stability_using_Nyquist_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Nyquist_criterion\n",
+"//example 7.17.7\n",
+"//page 244\n",
+"clf();\n",
+"s=%s;\n",
+"s1=-s;\n",
+"g=(2.2/(s*(s+1)*(s^2+2*s+2)))\n",
+"g1=(2.2/(s1*(s1+1)*(s1^2+2*s1+2)))\n",
+"GH=syslin('c',g);\n",
+"GH1=syslin('c',g1);\n",
+"nyquist(GH);\n",
+"nyquist(GH1);\n",
+"mtlb_axis([-2.5 0.2 -75 75]);\n",
+"disp('as the nyquist plot passes through the point -1+%i*0, so system is marginally stable and output represents sustained oscillations.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17_9: gain_margin_and_phase_margin.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption: gain_margin_and_phase_margin\n",
+"//example 7.17.9\n",
+"//page 245\n",
+"s=%s;\n",
+"syms w;\n",
+"s1=-s;\n",
+"gh=(32/(s*(s+sqrt(6))^3));\n",
+"g=sym((32/(s*(s+sqrt(6))^3)));\n",
+"s=%i*w;\n",
+"a=eval(g);\n",
+"w=sqrt(2);\n",
+"b=float(eval(abs(a)));\n",
+"disp(b,'at w=sqrt(2),|G(jw)H(jw)|=');\n",
+"GH=syslin('c',gh);\n",
+"gm=g_margin(GH);\n",
+"pm=p_margin(GH);\n",
+"disp(gm,'Gain margin=');\n",
+"disp(pm,'Phase margin=');\n",
+"disp('since gm=0 and pm=0, so system is marginally stable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.19_1: stability_using_bode_plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_bode_plot\n",
+"//example 7.19.1\n",
+"//page 280\n",
+"s=%s;\n",
+"g=50/((s+1)*(s+2));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"gm=g_margin(G)\n",
+"pm=p_margin(G)\n",
+"disp(gm,'gain_margin=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp('since gain and phase margin are both positive so system is stable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.19_2: gain_margin_and_phase_margin.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:gain_margin_and_phase_margin\n",
+"//example 7.19.2\n",
+"//page 282\n",
+"s=%s;\n",
+"g=((2*(s+0.25))/(s^2*(s+1)*(s+0.5)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.1; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"show_margins(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq=');\n",
+"show_margins(G);\n",
+"disp('since gain and phase margin are both negative so system is unstable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.19_3: stability_using_bode_plot.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_bode_plot\n",
+"//example 7.19.3\n",
+"//page 283\n",
+"s=%s;\n",
+"g=(48*(s+10))/(s*(s+20)*(s^2+2.4*s+16));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"gm=g_margin(G)\n",
+"pm=p_margin(G)\n",
+"disp(gm,'gain_margin=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp('since gain and phase margin are both positive so system is stable')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_10: Overall_Transfer_Function_and_Root_Locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Caption:overall_transfer_function_and_root_locus\n",
+"//example 7.24.10\n",
+"//page 314\n",
+"syms Ka Ke Kf Rf Lf eq N1 N2 N3 N4 N5\n",
+"//where Ka=amplifier_gain; Ke=error_detector_gain; Kf=motor_torque_const; Rf=field_resistance; Lf=field_inductance Jeq=moment_of_inertia; feq=coeff_of_viscous_friction;\n",
+"s=%s;\n",
+"d=N1/N2;\n",
+"e=N4/N3;\n",
+"f=N4/N5;\n",
+"n=N3/N5\n",
+"Ke=0.05; Kf=2; Rf=10; Lf=2; Jeq=0.5*10^-4; feq=10^-4; d=0.1; e=5; f=0.5;n=0.2;\n",
+"a=(1*Ke); //in series\n",
+"b=Kf/(Rf+s*Lf);\n",
+"c=1/(s*(Jeq*s+feq));\n",
+"g= (b*c) //in series\n",
+"h= (g*a) //in series\n",
+"j= (h*0.02) //in series\n",
+"k=j/(1+j*0.5);\n",
+"a1=1/20;\n",
+"cl=a1*k\n",
+"disp(cl,'C(s)/R(s)=');\n",
+"clf();\n",
+"G=syslin('c',cl)\n",
+"evans(G,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_11: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.11\n",
+"//page 308\n",
+"clc;\n",
+"s=%s;\n",
+"syms K\n",
+"clf();\n",
+"g=K*(s+0.1)/(s*(s-0.2)*(s^2+s+0.6));\n",
+"Z=2\n",
+"P=2\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s-0.2)*(s^2+s+0.6))+K*(s+0.1)\n",
+"CH=sym('(s*(s-0.2)*(s^2+s+0.6))+K*(s+0.1)');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"eq=(s*(s-0.2)*(s^2+s+0.6))\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"K=sym('-(s*(s-0.2)*(s^2+s+0.6))/(s+0.1)')\n",
+"d=diff(K,s)\n",
+"e=3*s^4+2*s^3+0.64*s^2+0.08*s-0.12\n",
+"r=roots(e);\n",
+"disp(r,'r=')\n",
+"disp('since -0.37 and 0.08 lies on root locus, so the breakaway point is -0.37 and 0.08 ')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(625*K^2-310*K+33)/(625*K-275)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=0.148 and 0.352');\n",
+"K1=0.148;\n",
+"K2=0.352\n",
+"a=((11-25*K1)/20)*s^2+K1/10//intersection of root locus with jw axis\n",
+"r1=roots(a)\n",
+"b=((11-25*K2)/20)*s^2+K2/10//intersection of root locus with jw axis\n",
+"r2=roots(b)\n",
+"disp(r1,r2,'root locus crosses imaginary axis at:')\n",
+"g=(s+0.1)/(s*(s-0.2)*(s^2+s+0.6));\n",
+"G=syslin('c',g)\n",
+"evans(G,200)\n",
+"xgrid(2)\n",
+"v=[-1 0.7 -2 2];\n",
+"mtlb_axis(v)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_1: root_locus_descriptio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_description\n",
+"//example 7.24.1\n",
+"//page 295\n",
+"clc;\n",
+"s=%s;\n",
+"syms K\n",
+"G=K/(s*(s+4));\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+4))+K\n",
+"CH=sym('(s*(s+4))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"eq=(s*(s+4))\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:')\n",
+"K=sym('-(s*(s+4))')\n",
+"d=diff(K,s)\n",
+"e=2*s+4\n",
+"P=2;\n",
+"Z=0;\n",
+"disp('since -2 lies on root locus so breakaway point is -2')\n",
+"for(k=0:1)\n",
+" A=((2*k+1)*180)/(P-Z);\n",
+" disp(A,'asymptote are at angle:')\n",
+"end\n",
+"x=((0-4)-0)/(P-Z) // (sum_of_P - sum_of_Z)/(P-Z)\n",
+"disp(x,'asymptotes intersect at ')\n",
+"disp('since |G(s)*H(s)|=1')\n",
+"disp('which gives K=8')\n",
+"k=8\n",
+"g=k/(s*(s+4))\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_2: root_locus_descriptio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_description\n",
+"//example 7.24.2\n",
+"//page 296\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+1)*(s+3))\n",
+"zeta=0.5\n",
+"//from given data \n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+1)*(s+3))+K\n",
+"CH=sym('(s*(s+1)*(s+3))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"K=sym('-(s^3+4*s^2+3*s)')\n",
+"d=diff(K,s)\n",
+"e=-3*s^2-8*s-3 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-0.45 is break away point since it lies on root locus')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(12-K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=12, for margianl stability');\n",
+"K=12;\n",
+"k=12\n",
+"a=4*s^2+k//intersection of root locus with imaginary plane\n",
+"r=roots(a)\n",
+"g=k/(s*(s+1)*(s+3))\n",
+"G=syslin('c',g)\n",
+"evans(g,8)\n",
+"xgrid(2)\n",
+"disp('the line theta=acos(zeta)=60 intersects root locus at sa=(-0.35+i0.6)')\n",
+"disp('the value of K at s=sa is find to be 1.66 ')\n",
+"disp('the value of K at s=-4')\n",
+"disp('K=12')\n",
+"disp('at K=1.66')\n",
+"k=1.66\n",
+"H=1\n",
+"G=k/(s*(s+1)*(s+3))\n",
+"CL=G/(1+G*H)\n",
+"disp(CL,'C(s)/R(s)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_3: root_locus_descriptio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus_description\n",
+"//example 7.24.3\n",
+"//page 299\n",
+"clc;\n",
+"s=%s;\n",
+"syms K\n",
+"G=K/(s*(s+6)*(s^2+4*s+13));\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+6)*(s^2+4*s+13))+K\n",
+"CH=sym('(s*(s+6)*(s^2+4*s+13))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"eq=(s*(s+6)*(s^2+4*s+13))\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:')\n",
+"phi1=180-(atan(3/2)*180/%pi)\n",
+"phi2=atan(3/4)*180/%pi\n",
+"phi3=90\n",
+"phi_p2=180-(phi1+phi2+phi3)\n",
+"phi_p3=-phi_p2\n",
+"disp(phi_p2,'angle of departure for -2+3i=')\n",
+"disp(phi_p3,'angle of departure for -2-3i=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"K=sym('-(s*(s+6)*(s^2+4*s+13))')\n",
+"d=diff(K,s)\n",
+"e=-(4*s^3+30*s^2+74*s+78)\n",
+"f=-e;\n",
+"r=roots(f);\n",
+"disp(r,'r=')\n",
+"disp('since -4.2 lies on root locus, so the breakaway point is -4.2 ')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(78-0.34*K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=229.4');\n",
+"K=229.4;\n",
+"k=229.4;\n",
+"a=29.2*s^2+229.4//intersection of root locus with s plane\n",
+"r1=roots(a)\n",
+"g=k/(s*(s+6)*(s^2+4*s+13));\n",
+"g=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)\n",
+"disp(r1,'the point of intersection of root locus with imaginary axis =')\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_4: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.4\n",
+"//page 301\n",
+"clc;\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+4)*(s^2+4*s+13))\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+4)*(s^2+4*s+13))+K\n",
+"CH=sym('(s*(s+4)*(s^2+4*s+13))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"c4=coeffs(CH,'s',4);\n",
+"b=[c0 c1 c2 c3 c4 ]\n",
+"routh=[b([5,3,1]);b([4,2]),0]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),routh(1,3),0]\n",
+"routh(3,1)=simple(routh(3,1))\n",
+"t=routh(2:3,1:2)\n",
+"l=simple(-det(t)/t(2,1))\n",
+"routh=[routh;l,0,0]\n",
+"routh=[routh;K,0,0]\n",
+"K=sym('(s*(s+4)*(s^2+4*s+13))')\n",
+"d=diff(K,s)\n",
+"e=(-4*s^3+24*s^2+58*s+52)\n",
+"r=roots(e)\n",
+"disp('since -2 lies on root locus so complex breakaway point is -2+i1.58 and -2-i1.58')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('((20-4K)/5)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=5');\n",
+"K=5;\n",
+"k=5\n",
+"a=5*s^2+5//intersection of root locus with s plane\n",
+"r=roots(a)\n",
+"g=k/(s*(s+2)*(s^2+2*s+2))\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)\n",
+"eq=(s*(s+4)*(s^2+4*s+13))\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:')\n",
+"phi1=180-(atan(3/2)*180/%pi)\n",
+"phi2=atan(3/2)*180/%pi\n",
+"phi3=90\n",
+"phi_p2=180-(phi1+phi2+phi3)\n",
+"phi_p3=-phi_p2\n",
+"disp(phi_p2,'angle of departure for -2+3i=')\n",
+"disp(phi_p3,'angle of departure for -2-3i=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_6: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.6\n",
+"//page 304\n",
+"clc;\n",
+"s=%s;\n",
+"syms K;\n",
+"clf();\n",
+"g=(K*(s+1)/(s^2+0.4*s+0.4));\n",
+"eq=(s^2+0.4*s+0.4)\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:');\n",
+"P=2;\n",
+"Z=1;\n",
+"k=0\n",
+" A=((2*k+1)*180)/(P-Z);\n",
+" disp(A,'asymptote are at angle:')\n",
+" CH=(s^2+0.4*s+0.4)+K*(s+1)\n",
+"CH=sym('(s^2+0.4*s+0.4)+K*(s+1)');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"K=sym('-(s^2+0.4*s+0.4)/(s+1)')\n",
+"d=diff(K,s)\n",
+"e=s*(s+2)\n",
+"disp('break away point s=-2 as it lies on root locus')\n",
+"disp('since |G(s)*H(s)|=1')\n",
+"disp('which gives K=3.6')\n",
+"k=3.6\n",
+"g=(k*(s+1))/(s^2+0.4*s+0.4);\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(1)\n",
+"v=[-20 1 -2 2]\n",
+"mtlb_axis(v);\n",
+"disp(' poles s=(-0.2+j0.6 and -0.2-j0.6)are equidistant from the zero s=-1, hence rootlocus plot is arc of the circle with centre s=-1 and radius 1.')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_7: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.7\n",
+"//page 306\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+2)*(s+4))\n",
+"//since Mp=40%, so .4=exp((-zeta*%pi)/(sqrt(1-zeta^2))\n",
+"zeta=0.3\n",
+"//from given data \n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+2)*(s+4))+K\n",
+"K=sym('-(s^3+6*s^2+8*s)')\n",
+"d=diff(K,s)\n",
+"e=-3*s^2-12*s-8 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-0.842 is break away point sinc it lies on root locus')\n",
+"CH=sym('s^3+6*s^2+8*s+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(48-K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=48');\n",
+"K=48;\n",
+"k=48\n",
+"a=6*s^2+48//intersection of root locus with imaginary plane\n",
+"r=roots(a)\n",
+"g=k/(s*(s+2)*(s+4))\n",
+"G=syslin('c',g)\n",
+"evans(g,8)\n",
+"xgrid(2)\n",
+"disp('the line theta=acos(zeta)=72.5 intersects root locus at sa=(-0.5+i1.65)')\n",
+"disp('the value of K at s=sa is find to be 14.87 for Mp=40%')\n",
+"K=14.87\n",
+"ts=4/0.5 //ts=4/(zeta*wn)\n",
+"Kv=limit(s*GH,s,0)\n",
+"Kv=eval(Kv)\n",
+"Kv=float(Kv)\n",
+"disp(Kv,'Kv=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_8: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.8\n",
+"//page 308\n",
+"clc;\n",
+"s=%s;\n",
+"syms K;\n",
+"GH=K/(s*(s+1)*(s+3))\n",
+"zeta=0.5\n",
+"//from given data \n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+1)*(s+3))+K\n",
+"CH=sym('(s*(s+1)*(s+3))+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"K=sym('-(s^3+4*s^2+3*s)')\n",
+"d=diff(K,s)\n",
+"e=-3*s^2-8*s-3 \n",
+"r1=roots(e)\n",
+"disp(r1,'roots=')\n",
+"disp('-0.45 is break away point since it lies on root locus')\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be marginally stable:');\n",
+"disp('(12-K)=0 ');\n",
+"disp('which gives:');\n",
+"disp('K=12, for margianl stability');\n",
+"K=12;\n",
+"k=12\n",
+"a=4*s^2+k//intersection of root locus with imaginary plane\n",
+"r=roots(a)\n",
+"disp(r,'intersection point of root locus with imaginary axis=')\n",
+"g=k/(s*(s+1)*(s+3))\n",
+"G=syslin('c',g)\n",
+"evans(g,8)\n",
+"xgrid(2)\n",
+"disp('for K=6')\n",
+"k=6;\n",
+"GH=k/(s*(s+1)*(s+3))\n",
+"gm=K/k //gm=K(marginal_stability)/K(desired)\n",
+"disp(gm,'gain_margin=')\n",
+"disp('the point where K=6 is s=1.2')\n",
+"pm=180+(-90-(atan(1.2/1)*180/%pi)-(atan(1.2/3)*180/%pi))\n",
+"disp(pm,'phase margin=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24_9: root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:root_locus\n",
+"//example 7.24.9\n",
+"//page 308\n",
+"clc;\n",
+"s=%s;\n",
+"syms K\n",
+"clf();\n",
+"g=(K*(s^2+4)/(s*(s+1)));\n",
+"Z=2\n",
+"P=2\n",
+"disp('the characterstics eq. is determined as:')\n",
+"CH=(s*(s+1))+K*(s^2+4)\n",
+"CH=sym('(s*(s+1))+K*(s^2+4)');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"eq=(s*(s+1))\n",
+"p=roots(eq)\n",
+"disp(p,'open loop poles are:')\n",
+"K=sym('-(s*(s+1))/(s^2+4)')\n",
+"d=diff(K,s)\n",
+"e=2*s^2-8*s-8\n",
+"r=roots(e);\n",
+"disp(r,'r=')\n",
+"disp('since -0.82 lies on root locus, so the breakaway point is -0.82 ')\n",
+"disp('by putting s=-0.82 in |G(s)*H(s)|=1, the value of K at s=-0.82 is K=0.2')\n",
+"k=0.2\n",
+"g=(k*(s^2+4)/(s*(s+1)));\n",
+"G=syslin('c',g)\n",
+"evans(g,200)\n",
+"xgrid(2)\n",
+"\n",
+"disp('part (b)')\n",
+"disp('by putting s=-0.69+i0.9 in |G(s)*H(s)|=1, K=0.464')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_1: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.1\n",
+"//page 202\n",
+"clc;\n",
+"s=%s;\n",
+"A=s^3+4.5*s^2+3.5*s+1.5;\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"B=routh_t(A)\n",
+"disp(B,'routh table:');\n",
+"c=0;\n",
+"for(i=1:n)\n",
+" if(B(i,1)<0)\n",
+" c=c+1;\n",
+" end\n",
+"end\n",
+"if(c>=1)\n",
+" disp('system is unstable')\n",
+"else('system is stable')\n",
+"end"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_2: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.2\n",
+"//page 202\n",
+"s=%s;\n",
+"A=s^3+4*10^2*s^2+5*10^4*s+2*10^6;\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"B=routh_t(A)\n",
+"disp(B,'routh table:');\n",
+"c=0;\n",
+"for(i=1:n)\n",
+" if(B(i,1)<0)\n",
+" c=c+1;\n",
+" end\n",
+"end\n",
+"if(c>=1)\n",
+" printf('\n system is unstable')\n",
+"else('system is stable')\n",
+"end"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_3: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.3\n",
+"//page 203\n",
+"s=%s;\n",
+"A=s^5+4*1.5*s^4+4*s^3+4*s^2+5*s+10;\n",
+"C=2*s+5;\n",
+"CL=A/C;\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"disp('=0',A,'characteristics eq is:')\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"B=routh_t(A)\n",
+"disp(B,'routh table:');\n",
+"c=0;\n",
+"r=1;\n",
+"for(i=1:n)\n",
+" if(B(i,1)<0)\n",
+" c=c+1;\n",
+" if(i==n & B(n,1)<0)\n",
+" r=r;\n",
+" else\n",
+" r=r+1;\n",
+" end\n",
+" end\n",
+"end\n",
+"if(c>=1)\n",
+" printf('system is unstable\n');\n",
+"else('system is stable ' );\n",
+"end\n",
+"mprintf('no. of roots with positive real parts=%d',r);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_4: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.4\n",
+"//page 203\n",
+"ieee (2)\n",
+"s=%s;\n",
+"A=s^5+s^4+2*s^3+2*s^2+11*s+10;\n",
+"b=coeff(A);\n",
+"n=length(b);\n",
+"B=routh_t(A);\n",
+"K=B;\n",
+"c=0;\n",
+"syms eps;\n",
+"x=limit(eps,eps,0);\n",
+"y=limit(((-1+2*eps)/eps),eps,0);\n",
+"z=limit(((-1+2*eps-10*eps^2)/(-1+2*eps)),eps,0);\n",
+"//after putting the limit we get:\n",
+"K(3,1)=0;\n",
+"K(4,1)=-%inf;\n",
+"K(5,1)=1;\n",
+"disp(K,'routh_table:')\n",
+"printf('There are two sign changes of first column ,hence the system is unstable \n' )\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_5: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.5\n",
+"//page 204\n",
+"s=%s;\n",
+"A=s^6+s^5+5*s^4+3*s^3+2*s^2-4*s-8;\n",
+"b=coeff(A)\n",
+"n=length(b)\n",
+"routh=[b([7,5,3,1]);b([6,4,2]),0];\n",
+"\n",
+"c=[routh(1,1),routh(1,3);routh(2,1),routh(2,3)]\n",
+"d=[routh(1,1),routh(1,4);routh(2,1),routh(2,4)]\n",
+"routh=[routh;-det(routh(1:2,1:2))/routh(2,1),-det(c)/routh(2,1),-det(d)/routh(2,1),0];\n",
+"routh1=routh;\n",
+"e=[routh(2,1),routh(2,2);routh(3,1),routh(3,2)]\n",
+"f=[routh(2,1),routh(2,3);routh(3,1),routh(3,3)]\n",
+"routh=[routh;-det(e)/routh(3,1),-det(f)/routh(3,1),0,0];\n",
+"disp('since all elements of fourth row are zero, so we make auxiliary equation')\n",
+"A=sym('2*s^4+6*s^2-8')\n",
+"B=diff(A,s)\n",
+"routh=[routh1;8,12,0,0]\n",
+"g=[routh(3,1),routh(3,3);routh(4,1),routh(4,3)]\n",
+"routh=[routh;-det(routh(3:4,1:2))/routh(4,1),-det(g)/routh(4,1),0,0];\n",
+"routh=[routh;-det(routh(4:5,1:2))/routh(5,1),0,0,0];\n",
+"routh=[routh;-det(routh(5:6,1:2))/routh(6,1),0,0,0]\n",
+"disp(routh,'routh table:')\n",
+"c=0;\n",
+"r=1;\n",
+"for(i=1:n)\n",
+" if(routh(i,1)<0)\n",
+" c=c+1;\n",
+" if(i==n & routh(n,1)<0)\n",
+" r=r;\n",
+" else\n",
+" r=r+1;\n",
+" end\n",
+" end\n",
+"end\n",
+"if(c>=1)\n",
+" printf('system is unstable\n')\n",
+"else('system is stable ' )\n",
+"end\n",
+"mprintf('no. of roots with positive real parts=%d',r);\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_6: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.6\n",
+"//page 206\n",
+"s=%s;\n",
+"syms T \n",
+"num=exp(-s*T);\n",
+"den=s*(s+2);\n",
+"G=num/den;\n",
+"H=1;\n",
+"a=(1+G*H);\n",
+"CL=G/a;\n",
+"CL=simple(CL);\n",
+"CH=s^2+2*s+exp(-s*T);\n",
+"//exp(-s*T)=1-sT+(sT)^2/2+....\n",
+"CH=s^2+(2-T)*s+1;\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"b=[c0 c1 c2]\n",
+"n=3;\n",
+"routh=[b([3,1]);b([2]),0];\n",
+"routh=[routh;simple(-det(routh)/routh(2,1)),0]\n",
+"disp(routh,'routh=');\n",
+"disp('for given system to be stable:');\n",
+"disp('2-T>0');\n",
+"disp('which gives:');\n",
+"disp('T<2');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_7_a: stability_using_Routh_hurwitz_criterion.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:stability_using_Routh-hurwitz_criterion\n",
+"//example 7.5.7.(a)\n",
+"//page 207\n",
+"s=%s;\n",
+"syms T K\n",
+"P=s*(s*(s+10)+T);\n",
+"CH=sym('s^3+10*s^2+T*s+K');\n",
+"disp('=0',CH,'characterstics_eq,CH=')\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable:');\n",
+"disp('((10*T-K)/10)>0 and K>0');\n",
+"disp('which gives:');\n",
+"disp('0<K<10T');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_7_b: value_of_K_of_characterstics_equatio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:value_of_K_of_characterstics_eq\n",
+"//example 7.5.7.(b)\n",
+"//page 207\n",
+"s=%s;\n",
+"syms K s1;\n",
+"CH=s^3+10*s^2+18*s+K\n",
+"s=s1-1;\n",
+"CH=eval(CH);\n",
+"CH=simple(CH);\n",
+"disp('=0',CH,'characterstics_eq,CH=');\n",
+"c0=coeffs(CH,'s1',0);\n",
+"c1=coeffs(CH,'s1',1);\n",
+"c2=coeffs(CH,'s1',2);\n",
+"c3=coeffs(CH,'s1',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable:');\n",
+"disp('((-(K-16))/7)>0 and K-9>0');\n",
+"disp('which gives:');\n",
+"disp('9<K<16');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.5_8: value_of_K_in_terms_of_T1_and_T2.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:value_of_K_in_terms_of_T1_and_T2\n",
+"//example 7.5.8\n",
+"//page 207\n",
+"s=%s;\n",
+"syms K T1 T2;\n",
+"m=s*(s*T1+1)*(s*T2+1)\n",
+"G=K/m;\n",
+"CH=1+G;\n",
+"disp('on simplyfying CH')\n",
+"CH=m+K;\n",
+"CH=simple(CH);\n",
+"disp('=0',CH,'characterstics_eq,CH=');\n",
+"c0=coeffs(CH,'s',0);\n",
+"c1=coeffs(CH,'s',1);\n",
+"c2=coeffs(CH,'s',2);\n",
+"c3=coeffs(CH,'s',3);\n",
+"b=[c0 c1 c2 c3]\n",
+"n=4;\n",
+"routh=[b([4,2]);b([3,1])];\n",
+"routh=[routh;-det(routh)/routh(2,1),0]\n",
+"t=routh(2:3,1:2)\n",
+"routh=[routh;-det(t)/t(2,1),0]\n",
+"disp(routh,'routh=')\n",
+"disp('for given system to be stable:');\n",
+"disp('K>0 and (-(K*T1*T2-T2-T1)/(T2+T1))>0');\n",
+"disp('which gives:');\n",
+"disp('0<K<((1/T1)+(1/T2))');"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/8-COMPENSATION_OF_CONTROL_SYSTEMS.ipynb b/Linear_Control_Systems_by_B_S_Manke/8-COMPENSATION_OF_CONTROL_SYSTEMS.ipynb
new file mode 100644
index 0000000..cb76d62
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/8-COMPENSATION_OF_CONTROL_SYSTEMS.ipynb
@@ -0,0 +1,210 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 8: COMPENSATION OF CONTROL SYSTEMS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8.6_1: design_suitable_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:design_suitable_compensator\n",
+"//example 8.6.1\n",
+"//page 339\n",
+"s=%s;\n",
+"clf();\n",
+"syms K;\n",
+"g=(K/(s*(1+0.2*s)));\n",
+"Kv=limit(s*g,s,0);//static velocity error coefficient\n",
+"//since Kv=10\n",
+"K=10;\n",
+"g=(10/(s*(1+0.2*s)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"xtitle('uncompensated system')\n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq_or_gain_cross_over_frequency=');\n",
+"disp('since P.M is less than desired value so we need phase lead network ')\n",
+"disp('selecting zero of lead compensating network at w=5.5rad/sec and pole at w=13.8rad/sec and applying gain to account attenuatin factor .')\n",
+"gc=(1+0.18*s)/(1+0.072*s)\n",
+"Gc=syslin('c',gc)\n",
+"disp(Gc,'transfer function of lead compensator=');\n",
+"G1=G*Gc\n",
+"disp(G1,'overall transfer function=');\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"figure();\n",
+"bode(G1, fmin, fmax);\n",
+"show_margins(G1)\n",
+"xtitle('compensated system')\n",
+"[gm,freqGM]=g_margin(G1);\n",
+"[pm,freqPM]=p_margin(G1);\n",
+"disp(pm,'phase_margin_of_compensated_system=');\n",
+"disp((freqPM*2*%pi),'gain_cross_over_frequency=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8.6_2: design_phase_lead_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:design_phase_lead_compensator\n",
+"//example 8.6.2\n",
+"//page 340\n",
+"clc;\n",
+"s=%s;\n",
+"clf();\n",
+"syms K;\n",
+"g=(K/(s^2*(1+0.05*s)));\n",
+"Ka=limit(s^2*g,s,0);//static acceleration error coefficient\n",
+"//since Ka=100\n",
+"K=100;\n",
+"g=(100/(s^2*(1+0.05*s)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"xtitle('uncompensated system')\n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq=');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq_or_gain_cross_over_frequency=');\n",
+"disp('since P.M is negaative so system is unstable ')\n",
+"disp('selecting zero of lead compensating network at w=5rad/sec and pole at w=54rad/sec and applying gain to account attenuatin factor .')\n",
+"gc=(1+0.2*s)/(1+0.0186*s)\n",
+"Gc=syslin('c',gc)\n",
+"disp(Gc,'transfer function of lead compensator=');\n",
+"G1=G*Gc\n",
+"disp(G1,'overall transfer function=');\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"figure();\n",
+"bode(G1, fmin, fmax) \n",
+"show_margins(G1)\n",
+"xtitle('compensated system')\n",
+"[gm,freqGM]=g_margin(G1);\n",
+"[pm,freqPM]=p_margin(G1);\n",
+"disp(pm,'phase_margin_of_compensated_system=');\n",
+"disp((freqPM*2*%pi),'gain_cross_over_frequency=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8.6_3: design_suitable_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:design_suitable_compensator\n",
+"//example 8.6.3\n",
+"//page 344\n",
+"clc;\n",
+"s=%s;\n",
+"clf();\n",
+"syms K;\n",
+"g=(K/(s*(1+0.5*s)*(1+0.2*s)));\n",
+"Kv=1/0.125//static velocity error coefficient(Kv=desired output velocity/steady state error)\n",
+"//since Kv=8, as system is type 1 , so K=Kv;\n",
+"K=8;\n",
+"g=(8/(s*(1+0.5*s)*(1+0.2*s)));\n",
+"G=syslin('c',g)\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"bode(G, fmin, fmax) \n",
+"show_margins(G)\n",
+"xtitle('uncompensated system')\n",
+"[gm,freqGM]=g_margin(G);\n",
+"[pm,freqPM]=p_margin(G);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq_or_phase_cross_over_frequency==');\n",
+"disp(pm,'phase_margin=');\n",
+"disp((freqPM*2*%pi),'phase_margin_freq_or_gain_cross_over_frequency=');\n",
+"disp('since gain crossover freq and phase crossover freq are very close to each other. So, system is marginally stable');\n",
+"disp('so we need phase lag network ')\n",
+"disp('selecting zero of lead compensating network at w=0.18rad/sec and pole at w=0.04rad/sec and applying gain to account attenuatin factor .')\n",
+"gc=(1+5.55*s)/(1+24.7*s)\n",
+"Gc=syslin('c',gc)\n",
+"disp(Gc,'transfer function of lead compensator=');\n",
+"G1=G*Gc\n",
+"disp(G1,'overall transfer function=');\n",
+"fmin=0.01; \n",
+"fmax=100; \n",
+"figure();\n",
+"bode(G1, fmin, fmax) \n",
+"show_margins(G1)\n",
+"xtitle('compensated system')\n",
+"[gm,freqGM]=g_margin(G1);\n",
+"[pm,freqPM]=p_margin(G1);\n",
+"disp(gm,'gain_margin=');\n",
+"disp((freqGM*2*%pi),'gain_margin_freq_or_phase_cross_over_frequency==');\n",
+"disp(pm,'phase_margin_of_compensated_system=');\n",
+"disp((freqPM*2*%pi),'gain_cross_over_frequency=');"
+ ]
+ }
+],
+"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
+}
diff --git a/Linear_Control_Systems_by_B_S_Manke/9-INTRODUCTION_TO_STATE_SPACE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb b/Linear_Control_Systems_by_B_S_Manke/9-INTRODUCTION_TO_STATE_SPACE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
new file mode 100644
index 0000000..c2d4f6c
--- /dev/null
+++ b/Linear_Control_Systems_by_B_S_Manke/9-INTRODUCTION_TO_STATE_SPACE_ANALYSIS_OF_CONTROL_SYSTEMS.ipynb
@@ -0,0 +1,836 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 9: INTRODUCTION TO STATE SPACE ANALYSIS OF CONTROL SYSTEMS"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_10: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.10\n",
+"//page 393\n",
+"s=%s;\n",
+"g=(s^2+6*s+8)/((s+3)*(s^2+2*s+5));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_11: Obtain_Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response\n",
+"//example 9.10.11\n",
+"//page 394\n",
+"s=%s;\n",
+"syms t\n",
+"A=[0 1;-2 0]\n",
+"B=[1 -1]\n",
+"x0=[1 1]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"//for calculating state transistion matrix\n",
+"ip=[0 0;0 0]\n",
+"i=1;j=1;\n",
+"for i=1:2\n",
+" for j=1:2\n",
+" ip(i,j)=ilaplace(r(i,j),s,t);\n",
+" j=j+1;\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"disp(ip,'state transistion matrix,ip(t)=');\n",
+"x=ip*x0\n",
+"y=x(1,1)-x(2,1)\n",
+"y=simple(y) //output\n",
+"disp(y,'time response of the system,y(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_12_ii: Obtain_Zero_State_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_zero_state_response\n",
+"//example 9.10.12_(ii)\n",
+"//page 395\n",
+"s=%s;\n",
+"syms t\n",
+"A=[0 1;-2 -1]\n",
+"B=[0 1]'\n",
+"x0=[1 0]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"m=r*B*(1/s);\n",
+"//for calculating zero state response\n",
+"x=[0;0]\n",
+"x(1,1)=ilaplace(m(1,1),s,t);\n",
+"x(2,1)=ilaplace(m(2,1),s,t);\n",
+"disp(x,'zero input response of the system,x(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_12_i: Obtain_Zero_Input_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_zero_input_response\n",
+"//example 9.10.12_(i)\n",
+"//page 395\n",
+"s=%s;\n",
+"syms t\n",
+"A=[0 1;-2 -1]\n",
+"B=[0 1]'\n",
+"x0=[1 0]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"q=det(p)//determinant of sI-A\n",
+"r=inv(p)//inverse of sI-A\n",
+"//for calculating state transistion matrix\n",
+"ip=[0 0;0 0]\n",
+"i=1;j=1;\n",
+"for i=1:2\n",
+" for j=1:2\n",
+" ip(i,j)=ilaplace(r(i,j),s,t);\n",
+" j=j+1;\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"disp(ip,'state transistion matrix,ip(t)=');\n",
+"x=ip*x0\n",
+"disp(x,'zero input response of the system,x(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_13: Obtain_Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response\n",
+"//example 9.10.13\n",
+"//page 397\n",
+"syms t;\n",
+"A=[0 1;-2 0]\n",
+"x0=[1 1]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"//since exp(At)=I+A*t+(A*t)^2/2+(A*t)^3/3+...\n",
+"I=eye(r,c)\n",
+"p=I+A*t+(A*t)^2/2+(A*t)^3/3\n",
+"x=p*x0;\n",
+"disp(x(1,1),'time response of the system,x1(t)=');\n",
+"disp(x(2,1),'time response of the system,x2(t)=');"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_14: Obtain_Time_Response_using_Diagonalization_Process.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response_using_diagonalization_process\n",
+"//example 9.10.14\n",
+"//page 398\n",
+"syms m11 m22 m21 m12 t;\n",
+"s=%s;\n",
+"poly(0,'l');\n",
+"A=[1 4;-2 -5]\n",
+"B=[0;1]\n",
+"C=[1;0]'\n",
+"x0=[1 0]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"I=eye(r,c);\n",
+"p=l*I-A;//l*I-A where I is identity matrix\n",
+"q=det(p)//determinant of lI-A\n",
+"\n",
+"//roots of q are -1 and -3\n",
+"l1=-1;\n",
+"l2=-3;\n",
+"//for determining modal matrix\n",
+"x1=[m11;m21]\n",
+"q1=(l1*I-A)*x1\n",
+"//on solving we find m11=1, m21=-0.5\n",
+"m11=1;m21=-0.5\n",
+"x2=[m12;m22]\n",
+"q2=(l2*I-A)*x1\n",
+"//on solving we find m12=1, m22=-1\n",
+"m12=1;m22=-1\n",
+"M=[m11 m12;m21 m22]\n",
+"M1=inv(M);\n",
+"k1=M1*A*M;\n",
+"z0=M1*x0;\n",
+"k2=M1*B\n",
+"Z=inv(s*I-k1)*z0+(inv(s*I-k1)*k2)*(1/s);\n",
+"X=M*Z\n",
+"x=[0;0]\n",
+"x(1,1)=ilaplace(X(1,1),s,t);\n",
+"x(2,1)=ilaplace(X(2,1),s,t);\n",
+"y=C*x\n",
+"disp(y,'output_equation_is,y(t)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_15: Obtain_Time_Response_using_Diagonalization_Process.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_time_response_using_diagonalization_process\n",
+"//example 9.10.15\n",
+"//page 403\n",
+"syms t;\n",
+"s=%s;\n",
+"poly(0,'l');\n",
+"A=[0 1;-6 -5]\n",
+"B=[0;1]\n",
+"C=[6 1]\n",
+"x0=[1 0]'\n",
+"[r c]=size(A);//size of matrix A\n",
+"I=eye(r,c);\n",
+"p=l*I-A;//l*I-A where I is identity matrix\n",
+"q=det(p)//determinant of lI-A\n",
+"//roots of q are -1 and -3\n",
+"l1=-2;\n",
+"l2=-3;\n",
+"//for determining vandermonde's matrix\n",
+"P=[1 1;l1 l2];\n",
+"P1=inv(P);\n",
+"k1=P1*A*P;\n",
+"z0=P1*x0;\n",
+"k2=P1*B\n",
+"Z=inv(s*I-k1)*z0+(inv(s*I-k1)*k2)*(1/s);\n",
+"X=P*Z\n",
+"X(2,1)=-5/(s^2+5*s+6)\n",
+"x=[0;0]\n",
+"x(1,1)=ilaplace(X(1,1),s,t);\n",
+"x(2,1)=ilaplace(X(2,1),s,t);\n",
+"y=C*x\n",
+"y=simple(y)\n",
+"disp(y,'output_equation_is,y(t)=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_16: Determine_Transfer_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_matrix\n",
+"//example 9.10.16\n",
+"//page 406\n",
+"clc;\n",
+"s=%s\n",
+"A=[1 -2;4 -5]\n",
+"B=[2;1]\n",
+"C=[1 1]\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B//transfer matrix\n",
+"disp(G,'transfer matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_17: Determine_Transfer_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_matrix\n",
+"//example 9.10.17\n",
+"//page 407\n",
+"s=%s\n",
+"A=[-3 1;0 -1]\n",
+"B=[1;1]\n",
+"C=[1 1]\n",
+"D=0;\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B//transfer matrix\n",
+"disp(G,'transfer matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_18: Determine_Transfer_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:determine_transfer_matrix\n",
+"//example 9.10.17\n",
+"//page 407\n",
+"s=%s\n",
+"A=[0 3;-2 -5]\n",
+"B=[1 1;1 1]\n",
+"C=[2 1;1 0]\n",
+"D=0;\n",
+"[r c]=size(A);//size of matrix A\n",
+"p=s*eye(r,c)-A;//s*I-A where I is identity matrix\n",
+"r=inv(p)//inverse of sI-A\n",
+"G=C*r*B//transfer matrix\n",
+"disp(G,'transfer matrix=')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_20: Check_for_Contrallability_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_of_system\n",
+"//example 9.10.20\n",
+"//page 410\n",
+"A=[0 1 0;0 0 1;0 -2 -3]\n",
+"B=[0 1;0 0;1 1]\n",
+"P=cont_mat(A,B);\n",
+"disp(P,'Controllability Matrix=');\n",
+"S=[P(1) P(4) P(7);P(2) P(5) P(8);P(3) P(6) P(9)];//collecting columns from P to form a square matrix (3*3)\n",
+"d=det(S);\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_21: Check_for_Contrallability_and_Observability.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_and_observability_of_system\n",
+"//example 9.10.21\n",
+"//page 411\n",
+"A=[0 1 0;0 0 1;-6 -11 -6]\n",
+"B=[1 0 1]'\n",
+"C=[10 5 1]\n",
+"P=cont_mat(A,B);\n",
+"disp(P,'Controllability Matrix=');\n",
+"d=det(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;\n",
+"P1=obsv_mat(A,C);\n",
+"disp(P1,'Observability Matrix=');\n",
+"d1=det(P1)\n",
+"if d1==0\n",
+" printf('matrix is singular, so system is unobservable');\n",
+"else\n",
+" printf('system is observable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_22: Check_for_Contrallability_and_Observability.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_and_observability_of_system\n",
+"//example 9.10.21\n",
+"//page 411\n",
+"s=%s;\n",
+"g=(10*(s+3))/((s+4)*(s+2)^2);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'Y(s)/U(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"A=SS(2)\n",
+"B=SS(3)\n",
+"C=SS(4)\n",
+"P=cont_mat(A,B);\n",
+"P=round(P)\n",
+"disp(P,'Controllability Matrix=');\n",
+"d=det(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;\n",
+"P1=obsv_mat(A,C);\n",
+"P1=round(P1);\n",
+"disp(P1,'Observability Matrix=');\n",
+"d1=det(P1)\n",
+"if d1==0\n",
+" printf('matrix is singular, so system is unobservable');\n",
+"else\n",
+" printf('system is observable');\n",
+"end"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_4_a: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.4_a\n",
+"//page 387\n",
+"s=%s;\n",
+"g=1/((s+1)*(s+3));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_4_b: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.4_b\n",
+"//page 387\n",
+"clc;\n",
+"s=%s;\n",
+"g=(2*s+1)/(s^2+2);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_5: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.5\n",
+"//page 388\n",
+"s=%s;\n",
+"g=(s+3)/(s^2+3*s+4);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_6: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.6\n",
+"//page 389\n",
+"s=%s;\n",
+"g=(s^2+3*s+2)/(s^3+9*s^2+26*s+24);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_7: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.7\n",
+"//page 390\n",
+"s=%s;\n",
+"g=(s+3)/((s+1)*(s+2));\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.10_9: Obtain_State_Matrix.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:obtain_state_matrix\n",
+"//example 9.10.9\n",
+"//page 392\n",
+"s=%s;\n",
+"g=(10*(s+3))/((s+4)*(s+2)^2);\n",
+"CL=syslin('c',g);\n",
+"disp(CL,'C(s)/R(s)=');\n",
+"SS=tf2ss(CL)\n",
+"[Ac,Bc,U,ind]=canon(SS(2),SS(3))\n",
+"disp(SS,'state space matrix=')\n",
+"disp(Ac,'Ac',Bc,'Bc',U,'U',ind,'ind')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.8_1: Check_for_Contrallability_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_of_system\n",
+"//example 9.8.1\n",
+"//page 381\n",
+"A=[1 1;0 -1]\n",
+"B=[1;0]\n",
+"P=cont_mat(A,B);\n",
+"disp(P,'Controllability Matrix=');\n",
+"d=determ(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.8_2: Check_for_Contrallability_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_contrallability_of_system\n",
+"//example 9.8.2\n",
+"//page 381\n",
+"A=[-2 0;0 -1]\n",
+"B=[1;1]\n",
+"P=cont_mat(A,B);\n",
+"disp(P,'Controllability Matrix=');\n",
+"d=determ(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is uncontrollable');\n",
+"else\n",
+" printf('system is controllable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.9_1_a: Check_for_Observability_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_observability_of_system\n",
+"//example 9.9.1_a\n",
+"//page 383\n",
+"A=[0 1;-2 -3]\n",
+"B=[0;1]\n",
+"C=[1 1]\n",
+"P=obsv_mat(A,C);\n",
+"disp(P,'Observability Matrix=');\n",
+"d=determ(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is unobservable');\n",
+"else\n",
+" printf('system is observable');\n",
+"end;"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.9_1_b: Check_for_Observability_of_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//caption:check_for_observability_of_system\n",
+"//example 9.9.1_b\n",
+"//page 383\n",
+"A=[-2 1;0 1]\n",
+"B=[1;1]\n",
+"C=[1 1]\n",
+"P=obsv_mat(A,C);\n",
+"disp(P,'Observability Matrix=');\n",
+"d=determ(P)\n",
+"if d==0\n",
+" printf('matrix is singular, so system is unobservable');\n",
+"else\n",
+" printf('system is observable');\n",
+"end;"
+ ]
+ }
+],
+"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
+}