summaryrefslogtreecommitdiff
path: root/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin
diff options
context:
space:
mode:
authorprashantsinalkar2020-04-14 10:19:27 +0530
committerprashantsinalkar2020-04-14 10:23:54 +0530
commit476705d693c7122d34f9b049fa79b935405c9b49 (patch)
tree2b1df110e24ff0174830d7f825f43ff1c134d1af /Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin
parentabb52650288b08a680335531742a7126ad0fb846 (diff)
downloadall-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.gz
all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.tar.bz2
all-scilab-tbc-books-ipynb-476705d693c7122d34f9b049fa79b935405c9b49.zip
Initial commit
Diffstat (limited to 'Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin')
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/2-Dynamic_Models.ipynb127
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/3-Dynamic_Responses.ipynb912
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/4-Basic_properties_of_feedback.ipynb340
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/5-The_Root_Locus_Design_method.ipynb845
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/6-The_Frequency_Response_Design_Method.ipynb1164
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/7-State_Space_Design.ipynb2207
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/8-Digital_Control.ipynb174
-rw-r--r--Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/9-Nonlinear_Systems.ipynb638
8 files changed, 6407 insertions, 0 deletions
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/2-Dynamic_Models.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/2-Dynamic_Models.ipynb
new file mode 100644
index 0000000..391c8dc
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/2-Dynamic_Models.ipynb
@@ -0,0 +1,127 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 2: Dynamic Models"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2.1_b: step_response_of_Cruise_control_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 2.1\n",
+"//(b) step response of Cruise control system\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Cruise control parameters\n",
+"m=1000;\n",
+"b=50;\n",
+"u=500;\n",
+"\n",
+"// Transfer function\n",
+"s=%s; // or \n",
+"s=poly(0,'s');\n",
+"sys=syslin('c',(1/m)/(s+b/m))\n",
+"\n",
+"//step response to u=500;\n",
+"t=0:0.5:100;\n",
+"v=csim('step',t,u*sys);\n",
+"plot2d(t,v,2)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Responses of car velocity to a step in u','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2.5_b: step_response_of_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 2.5\n",
+"//(b) step response of pendulum\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Pendulum parameters\n",
+"m=0.5;\n",
+"l=1;\n",
+"g=9.81;\n",
+"\n",
+"// Transfer function\n",
+"s=%s;\n",
+"sys=syslin('c',(1/(m*l^2))/(s^2+g/l));\n",
+"\n",
+"//step response to u=500;\n",
+"t=0:0.02:10;\n",
+"theta=csim('step',t,sys);\n",
+"plot(t,theta*57.3);\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script to set figure properties\n",
+"title('Response of pendulum to a step input in the applied torque',...\n",
+"'fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel('Pendulum angle (degree)','fontsize',2);\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/3-Dynamic_Responses.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/3-Dynamic_Responses.ipynb
new file mode 100644
index 0000000..07ed3b0
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/3-Dynamic_Responses.ipynb
@@ -0,0 +1,912 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 3: Dynamic Responses"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.10: Incorrect_use_of_final_value_theorem.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.10\n",
+"\n",
+"//Computing final value for unstable system to show the incorrect \n",
+"// use of final value theorem.\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"s=poly(0,'s');\n",
+"num=3;\n",
+"den=s*(s-2);\n",
+"Ys=syslin('c',num/den);\n",
+"\n",
+"//final value theorem, lim s-->0 in s*Y(s)\n",
+"Y_final=horner(s*Ys,0);\n",
+"disp(Y_final,'The final value of the output y is:');\n",
+"disp('The final value computed is incorrect as the system...\n",
+" response is unbounded');\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.11: DC_gain_of_the_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.11\n",
+"//Computing DC gain of the system.\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer Function\n",
+"s=poly(0,'s');\n",
+"num=3*(s+2);\n",
+"den=(s^2+2*s+10);\n",
+"Ys=syslin('c',num/den);\n",
+"\n",
+"//The DC gain of the system Y(s) as s-->0 is\n",
+"DC_Gain=horner(Ys,0)\n",
+"disp(DC_Gain,'The DC gain of the system is:')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.14: Partial_fraction_expansion_for_distinct_real_roots.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.14\n",
+"//Partial fraction expansion for distinct real roots\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// Transfer function\n",
+"s=%s;\n",
+"num=2;\n",
+"p1=(s+1);\n",
+"p2=(s+2);\n",
+"p3=(s+4);\n",
+"sys=syslin('c',num/(p1*p2*p3))\n",
+"\n",
+"//Partial fraction expansion is: sys= r1/p1 + r2/p2 + r3/p3\n",
+"//residue calculation\n",
+"r1=residu(num,p1,(p2*p3))\n",
+"r2=residu(num,p2,(p1*p3))\n",
+"r3=residu(num,p3,(p1*p2))\n",
+"\n",
+"disp([r1 r2 r3]','Residues of the poles p1, p2 and p3 are')\n",
+"disp([roots(p1), roots(p2), roots(p3)]','Poles p1, p2 and p3 are at')\n",
+"disp('k=[]')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.15: Cruise_Control_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.15 Cruise Control Transfer Function.\n",
+"//Coefficients of numerator and denominator of the transfer function\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// Transfer function coefficients\n",
+"num=[0.001 0];\n",
+"den=[0 0.05 1];\n",
+"\n",
+"// Transfer function\n",
+"Ns=poly(num,'s','coeff');\n",
+"Ds=poly(den,'s','coeff');\n",
+"sys=syslin('c',Ns/Ds);\n",
+"\n",
+"//gain (K) pole (P) and zeros (Z) of the system\n",
+"temp=polfact(Ns);\n",
+"Z=roots(Ns); //locations of zeros\n",
+"P=roots(Ds); //locations of poles\n",
+"K=temp(1); //first entry is always gain\n",
+"disp( K,'Gain', P, 'Poles',Z,'Zeros',)\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.16: DC_Motor_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.16 DC Motor Transfer Function.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Coefficients of numerator and denominator of the transfer function\n",
+"numb=[100];\n",
+"denb=[0 101 10.1 1];\n",
+"\n",
+"// Transfer function\n",
+"Ns=poly(numb,'s','coeff');\n",
+"Ds=poly(denb,'s','coeff');\n",
+"sysb=syslin('c',Ns/Ds);\n",
+"\n",
+"//gain (K) pole (P) and zeros (Z) of the system\n",
+"temp=polfact(Ns);\n",
+"Z=roots(Ns); //locations of zeros\n",
+"P=roots(Ds); //locations of poles\n",
+"K=temp(1); //first entry is always gain\n",
+"disp( K,'Gain', P, 'Poles',Z,'Zeros',)\n",
+"\n",
+"//Transient response of DC Motor (consider velocity as output)\n",
+"s=%s;\n",
+"t=linspace(0,5,501);\n",
+"y=csim('step',t,sysb*s) \n",
+"plot(t,y)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response of DC Motor','fontsize',3)\n",
+"xlabel('$Time\,\, t(sec.)$','fontsize',3)\n",
+"ylabel('$\omega\,\,(rad/sec)$','fontsize',3)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.17: Transformations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.17 Transformations\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"//-------------------------------------------------------------------\n",
+"//Coefficients of numerator and denominator of the transfer function\n",
+"numG=[9 3];\n",
+"denG=[25 6 1];\n",
+"\n",
+"// Transfer function\n",
+"Ns=poly(numG,'s','coeff');\n",
+"Ds=poly(denG,'s','coeff');\n",
+"sysG=syslin('c',Ns/Ds);\n",
+"\n",
+"//gain (K) pole (P) and zeros (Z) of the system\n",
+"temp=polfact(Ns);\n",
+"Z=roots(Ns); //locations of zeros\n",
+"P=roots(Ds); //locations of poles\n",
+"K=temp(1); //first entry is always gain\n",
+"disp( K,'Gain', P, 'Poles',Z,'Zeros',)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.18: Satellite_Transfer_Function.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.18 Satellite Transfer Function\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//(a)\n",
+"//Given\n",
+"d=1 //meters\n",
+"I=5000 //Kg-meter^2\n",
+"\n",
+"//Coefficients of numerator and denominator of the transfer function\n",
+"// of satellite\n",
+"numG=[d/I 0];\n",
+"denG=[0 0 1];\n",
+"\n",
+"// Transfer function\n",
+"Ns=poly(numG,'s','coeff');\n",
+"Ds=poly(denG,'s','coeff');\n",
+"sysG=syslin('c',Ns/Ds);\n",
+"t=0:0.01:10;\n",
+"[i j]=size(t);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//(b)\n",
+"// Thrust input after 5 sec.\n",
+"u=zeros(1,j);\n",
+"w=find(t>=5 & t<=5+0.1);\n",
+"u(w)=25;\n",
+"plot(t,u);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response of the satellite...\n",
+" (a) Thrust input','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Fc','fontsize',2)\n",
+"\n",
+"//Transient response of the satellite to the thrust input as a pulse \n",
+"sysd=dscr(sysG,0.01); //sample data system model\n",
+"y=flts(u,sysd); //impulse response \n",
+"figure, plot(t,y*180/%pi);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response of the satellite(double-pulse)...\n",
+" (b) satellite attitude','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('$\theta(deg)$','fontsize',2)\n",
+"//------------------------------------------------------------------\n",
+"// Thrust input double-pulse.\n",
+"u=zeros(1,j);\n",
+"w1=find(t>=5 & t<=5+0.1);\n",
+"u(w1)=25;\n",
+"w2=find(t>=6.1 & t<=6.1+0.1);\n",
+"u(w2)=-25;\n",
+"figure,\n",
+"plot(t,u);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response of the satellite (double-pulse)...\n",
+" (a) Thrust input','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Fc','fontsize',2)\n",
+"\n",
+"//Transient response of the satellite to the thrust input as a pulse \n",
+"sysd=dscr(sysG,0.01); //sample data system model\n",
+"y=flts(u,sysd); //impulse response \n",
+"figure, plot(t,y*180/%pi);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response of the satellite(double-pulse)...\n",
+" (b) satellite attitude','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('$\theta(deg)$','fontsize',2)\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.21: Transfer_function_of_a_simple_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.21\n",
+"//Series, Parallel and Feedback connections of TF blocks \n",
+"//to get effective TF.\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function block G1\n",
+"num1=[2];\n",
+"den1=[1];\n",
+"Ns=poly(num1,'s','coeff');\n",
+"Ds=poly(den1,'s','coeff');\n",
+"sysG1=syslin('c',Ns/Ds);\n",
+"\n",
+"//Transfer function block G2\n",
+"num2=[4];\n",
+"den2=[0 1];\n",
+"Ns=poly(num2,'s','coeff');\n",
+"Ds=poly(den2,'s','coeff'); \n",
+"sysG2=syslin('c',Ns/Ds);\n",
+"\n",
+"//Transfer function block G4\n",
+"num4=[1];\n",
+"den4=[0 1];\n",
+"Ns=poly(num4,'s','coeff');\n",
+"Ds=poly(den4,'s','coeff');\n",
+"sysG4=syslin('c',Ns/Ds);\n",
+"\n",
+"//Transfer function block G6\n",
+"num6=[1];\n",
+"den6=[1];\n",
+"Ns=poly(num6,'s','coeff');\n",
+"Ds=poly(den6,'s','coeff');\n",
+"sysG6=syslin('c',Ns/Ds);\n",
+"\n",
+"//Effective transfer function\n",
+"// (+) operator for paralle connection, \n",
+"// (*) operator for series connection\n",
+"// (/.)operator for feedback connection\n",
+"sysG=(sysG1 + sysG2) * sysG4 /. sysG6\n",
+"disp(sysG, 'The effective transfer function is')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.22: Response_Versus_Pole_Locations_Real_Roots.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.22 Response Versus Pole Locations, Real Roots\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function\n",
+"numH=[1 2];\n",
+"denH=[2 3 1];\n",
+"Ns=poly(numH,'s','coeff');\n",
+"Ds=poly(denH,'s','coeff');\n",
+"sysH=syslin('c',Ns/Ds);\n",
+"\n",
+"//Pole-zero locations\n",
+"//Partial fraction method to see the effect of sperated poles\n",
+"temp=polfact(Ds);\n",
+"p1s=temp(2);\n",
+"p2s=temp(3);\n",
+"\n",
+"//residues at poles\n",
+"r1=residu(Ns,p1s,p2s);\n",
+"r2=residu(Ns,p2s,p1s);\n",
+"\n",
+"//Note that - H1(s)+H2(s)=H(s)\n",
+"H1s=syslin('c',r1/p1s);\n",
+"H2s=syslin('c',r2/p2s);\n",
+"\n",
+"//impulse response of the H1(s), H2(s) and H(s)\n",
+"t=0:0.02:10;\n",
+"h1=csim('impuls',t,H1s);\n",
+"h2=csim('impuls',t,H2s);\n",
+"h=csim('impuls',t,sysH);\n",
+"figure, \n",
+"plot(t,h1,'r--',t,h2,'m-.', t, h, 'b')\n",
+"plot(t,h2,'m-.')\n",
+"plot(t,h)\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['impulse response of the system and subsystems with...\n",
+" independent poles.';'(h1(t) is faster than h2(t))'],'fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('h(t), h1(t), h2(t)','fontsize',2)\n",
+"h=legend('h1(t) with pole at -2','h2(t) with pole at -1'...\n",
+",'h(t)=h1(t)+h2(t)')\n",
+"h.legend_location = 'in_upper_right'\n",
+"h.fill_mode='off'\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.23: Oscillatory_Time_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.23 Oscillatory Time Response\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function of second order underdamped system\n",
+"numH=[1 2];\n",
+"denH=[5 2 1];\n",
+"Ns=poly(numH,'s','coeff');\n",
+"Ds=poly(denH,'s','coeff');\n",
+"sysH=syslin('c',Ns/Ds);\n",
+"\n",
+"//damping factor (xi) and natural frequency (wn)\n",
+"[wn xi]=damp(sysH);\n",
+"wn=wn(1);\n",
+"xi=xi(1);\n",
+"sigma=xi*wn;\n",
+"wd=wn*sqrt(1-xi^2);\n",
+"\n",
+"//denominator in sigma-wn form H(s)=H1(s)+H2(s)\n",
+"s=%s;\n",
+"p=(s+sigma)^2+wd^2\n",
+"temp=polfact(Ns);\n",
+"k=temp(1),zr=temp(2);\n",
+"h1=(s+sigma)/p;\n",
+"h2=-((s+sigma)-temp(2))*wd/p;\n",
+"H1s=syslin('c',k*h1);\n",
+"H2s=syslin('c',k*h2/wd);\n",
+"\n",
+"// responses with exponential envelope\n",
+"Env=syslin('c',k/(s+sigma));\n",
+"t=0:0.02:10;\n",
+"//impulse response\n",
+"ht=csim('impuls',t,sysH);\n",
+"envt=csim('impuls',t,Env);\n",
+"envt_neg=csim('impuls',t,-Env);\n",
+"\n",
+"plot(t,ht)\n",
+"plot(t,envt,'r--')\n",
+"plot(t,envt_neg,'r--')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Impulse response of the underdamped system','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('h(t)','fontsize',2)\n",
+"xset('font',1,2)\n",
+"xstring(1,0.75,'$e^{-\sigma t}$',0,0)\n",
+"xstring(1,-0.85,'$-e^{-\sigma t}$',0,0)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.25: Aircraft_Response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.25 Aircraft Response\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//(a)impulse response of aircraft\n",
+"\n",
+"//Transfer function of aircraft\n",
+"numG=[-6 1];\n",
+"denG=[0 13 4 1];\n",
+"Ns=30*poly(numG,'s','coeff');\n",
+"Ds=poly(denG,'s','coeff');\n",
+"u=-1 //impulsive elevator input of 1 degree\n",
+"sysG=syslin('c',u*Ns/Ds);\n",
+"\n",
+"//impulse response\n",
+"t=0:0.02:10;\n",
+"gt=csim('impuls',t,sysG);\n",
+"plot(t,gt)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Response of an airplanes altitude to an impulsive elevator input','fontsize',3)\n",
+"xlabel('Time (sec.)','fontsize',2)\n",
+"ylabel('Altitude (ft)','fontsize',2)\n",
+"\n",
+"//final value theorem, lim s-->0 in s*G(s)\n",
+"s=%s;\n",
+"gt_final=horner(s*sysG,0)\n",
+"disp(gt_final,'The final value of the output altitude is:')\n",
+"//------------------------------------------------------------------\n",
+"//(b)response specifications\n",
+"\n",
+"//damping factor (xi) and natural frequency (wn)\n",
+"[wn xi]=damp(sysG);\n",
+"wn=wn(2);//natural frequency (wn)\n",
+"xi=xi(2);//damping factor\n",
+"disp(wn,xi,'Damping factor and natural frequency (rad)...\n",
+" of the response are:')\n",
+"\n",
+"tr=1.8/wn; //rise time\n",
+"disp(tr,'Rise time (sec) of the response is:')\n",
+"\n",
+"sigma=xi*wn\n",
+"ts=4.6/sigma; //settling time\n",
+"disp(ts,'Settling time (sec) of the response is:')\n",
+"\n",
+"Mp=exp(-xi*%pi/sqrt(1-xi^2))\n",
+"wd=wn*sqrt(1-xi^2);\n",
+"tp=%pi/wd;\n",
+"disp(tp, Mp,'Overshoot and time of overshoot (sec)...\n",
+" in the response are:')\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.29: Stability_versus_parameter_range.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.29 \n",
+"//Stability versus parameter range\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Stability versus parameter range\n",
+"\n",
+"numT=[-1];//zeros\n",
+"denT=[1 0 -6];//poles\n",
+"Ns=poly(numT,'s','roots');\n",
+"Ds=poly(denT,'s','roots'); \n",
+"Gfs=syslin('c',Ns/Ds); //forward transfer function block\n",
+"\n",
+"num=[1];\n",
+"den=[1 0];\n",
+"Ns=poly(num,'s','coeff');\n",
+"Ds=poly(den,'s','coeff');\n",
+"Hs=syslin('c',Ns/Ds); //feedback transfer function block\n",
+"\n",
+"//check the step responses with the forward path gain K=7.5, 13, 25\n",
+"t=0:0.02:12;\n",
+"i=1;\n",
+"\n",
+"for K=[7.5, 13, 25]\n",
+" sysT= (K * Gfs) /. Hs;\n",
+" yt(i,:)=csim('step',t,sysT);\n",
+" i=i+1;\n",
+"end\n",
+"//Step response\n",
+"plot(t',yt')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response for different values of K','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('y(t)','fontsize',2)\n",
+"h=legend('K=7.5','K=13', 'K=25')\n",
+"h.legend_location = 'in_upper_right'\n",
+"h.fill_mode='off'\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.30: Stability_versus_two_parameter_ranges.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.30\n",
+"//Stability versus two parameter ranges\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Stability versus parameter ranges\n",
+"\n",
+"num=[1 0];//zeros\n",
+"den=[-1 -2];//poles\n",
+"Ns=poly(num,'s','coeff');\n",
+"Ds=poly(den,'s','roots'); \n",
+"Gfs=syslin('c',Ns/Ds); //forward transfer function block\n",
+"\n",
+"num=[1];\n",
+"den=[1 0];\n",
+"Ns=poly(num,'s','coeff');\n",
+"Ds=poly(den,'s','coeff');\n",
+"Hs=syslin('c',Ns/Ds); //feedback transfer function block\n",
+"\n",
+"//check the step responses with the forward, path gain K=7.5, 13, 25\n",
+"t=0:0.02:12;\n",
+"i=1;\n",
+"num=[5 10;1 1;0 1];\n",
+"\n",
+"for i=1:3\n",
+" den=[0 1];\n",
+" Ns=poly(num(i,:),'s','coeff');\n",
+" Ds=poly(den,'s','coeff');\n",
+" Gcs=syslin('c',Ns/Ds); //Controller transfer function block\n",
+" sysT= Gcs * Gfs /. Hs;\n",
+" yt(i,:)=csim('step',t,sysT);\n",
+" i=i+1;\n",
+"end\n",
+"\n",
+"//Transient response for different values of K and Ki\n",
+"plot(t',yt')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Transient response for the system','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('y(t)','fontsize',2)\n",
+"xset('font',1,1)\n",
+"xstring(1.4,1.05,'$K=10,K_I=5$');\n",
+"xstring(3.3,0.8,'$K=1,K_I=1$');\n",
+"xstring(5.5,0.35,'$K=1,K_I=0$') \n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.4: Frequency_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.4\n",
+"//Frequency response\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//(a) Frequency response of 1/(s+k)\n",
+"k=1;\n",
+"fmin=1e-2;\n",
+"fmax=1e2;\n",
+"// Transfer function\n",
+"s=poly(0,'s');\n",
+"sysH=syslin('c',1/(s+k))\n",
+"\n",
+"//Frequency response for k=1 \n",
+"//Note that - magnitude plot semilog plot unlike log-log plot in the book.\n",
+"bode(sysH,fmin,fmax)\n",
+"title('Frequency response for k=1','fontsize',3)\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//(b) Response to u=sin(10*t);\n",
+"t=0:0.02:10;\n",
+"u=sin(10*t);\n",
+"y=csim(u,t,sysH);\n",
+"figure, plot(t,y)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Complete transient response','fontsize',3)\n",
+"xlabel('Time (sec.)','fontsize',2)\n",
+"ylabel('Output','fontsize',2)\n",
+"\n",
+"//phase lag\n",
+"figure, plot(t,y)\n",
+"plot(t,u,'r')\n",
+"zoom_rect([9 -1 10 1])\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Phase lag between output and input','fontsize',3)\n",
+"xlabel('Time (sec.)','fontsize',2)\n",
+"ylabel('Output, Input','fontsize',2)\n",
+"h=legend('y(t)','u(t)')\n",
+"h.legend_location = 'in_upper_right'\n",
+"h.fill_mode='off'\n",
+"\n",
+"// time lag\n",
+"w=find(t>=9.4 & t<=10);\n",
+"T=t(w);\n",
+"Y=y(w);\n",
+"U=u(w);\n",
+"wu=find(U==max(U))\n",
+"wy=find(Y==max(Y))\n",
+"\n",
+"//Responses\n",
+"plot2d3(T(wy),Y(wy))\n",
+"plot2d3(T(wu),U(wu))\n",
+"delta_t=T(wu)-T(wy); //time lag sec.\n",
+"xstring(9.64,-0.1,'$\delta t$',0,0)\n",
+"xarrows([9.58;9.72], [0;0], 0.7, 1)\n",
+"xarrows([9.72;9.58], [0;0], 0.7, 1)\n",
+"t=get('hdl') \n",
+"disp(abs(delta_t), 'Time lag of output in sec. is')\n",
+"disp(abs(delta_t)*10, 'Phase lag of output in radians is')\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.8: Partial_fraction_expansion_for_distinct_real_roots.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.8\n",
+"//Partial fraction expansion for distinct real roots.\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Partial fraction expansion for distinct real roots\n",
+"// Transfer function\n",
+"s=%s;\n",
+"num=(s+2)*(s+4)\n",
+"p1=s;\n",
+"p2=(s+1);\n",
+"p3=(s+3);\n",
+"sys=syslin('c',num/(p1*p2*p3))\n",
+"//------------------------------------------------------------------\n",
+"//Partial fraction expansion is: sys= r1/p1 + r2/p2 + r3/p3\n",
+"//residue calculation\n",
+"r1=residu(num,p1,(p2*p3))\n",
+"r2=residu(num,p2,(p1*p3))\n",
+"r3=residu(num,p3,(p1*p2))\n",
+"\n",
+"disp([r1 r2 r3]','Residues of the poles p1, p2 and p3 are')\n",
+"disp([roots(p1), roots(p2), roots(p3)]','Poles p1, p2 and p3 are at')\n",
+"disp('k=[]')\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3.9: Final_value_theorem.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 3.9\n",
+"//Computing final value (use of final value theorem).\n",
+"\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//Computing final value (use of final value theorem)\n",
+"// Output of the system\n",
+"s=poly(0,'s');\n",
+"num=3*(s+2);\n",
+"den=s*(s^2+2*s+10);\n",
+"Ys=syslin('c',num/den);\n",
+"\n",
+"\n",
+"//final value theorem, lim s-->0 in s*Y(s)\n",
+"\n",
+"Y_final=horner(s*Ys,0)\n",
+"disp(Y_final,'The final value of the output y is:')\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/4-Basic_properties_of_feedback.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/4-Basic_properties_of_feedback.ipynb
new file mode 100644
index 0000000..b86750c
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/4-Basic_properties_of_feedback.ipynb
@@ -0,0 +1,340 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 4: Basic properties of feedback"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.6: PID_Control_of_DC_Motor_Speed.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 4.6 \n",
+"//PID Control of DC Motor Speed.\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//NOTE THAT--\n",
+"\n",
+"//The model as given in matlab program for this example in the book is\n",
+"\n",
+"//num=Ra*s + La*s^2 ;\n",
+"//den=Ke*ki + (Ra*Ke*Ke+Ke*kp)*s + (Ra*b+Ke*Ke+Ke*kd)*s^2 + Jm*La*s^3;\n",
+"\n",
+"//this does not match to the model of DC motor given on page 43. \n",
+"//Also, if we assume this model, disturbance response given \n",
+"//in figure 4.13 (a) \n",
+"//is different from expected.\n",
+"//For instance, with P control, output should asymptotically go to 0\n",
+"//for disturbance step input, because numerator is s(Ra + La*s) \n",
+"//and system is type 0 (no pole at origin).\n",
+"//i.e. y(inf)=lim s->0 s*Y(s)= s*[s(Ra + La*s)/den]*1/s=0;\n",
+"\n",
+"//In following code, we have considered correct model of DC motor as \n",
+"//given on page 43. Note that, this model must have been used \n",
+"//by authors of the book for \n",
+"//step reference tracking as it is correctly shown in figure 4.13 (b)\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"// System parameters\n",
+"Jm=0.0113; // N-m-s^2/rad\n",
+"b=0.028; // N-m-s/rad\n",
+"La=0.1; // henry\n",
+"Ra=0.45; // ohms\n",
+"Kt=0.067 // n-m/amp\n",
+"Ke=0.067; // V-sec/amp\n",
+"\n",
+"// Controller parameters\n",
+"kp=3;\n",
+"ki=15; // sec^-1\n",
+"kd=0.3; // sec\n",
+"\n",
+"// DC Motor Transfer function as given on page 43 of book (edition 5)\n",
+"//G=Kt/[Jm*La s^2 + (Jm*Ra + La*b)s +(Ra*b +Kt*Ke)]\n",
+"s=%s;\n",
+"num=[Kt];\n",
+"den=[(Ra*b +Kt*Ke) (Jm*Ra + La*b) Jm*La];\n",
+"Ns=poly(num,'s','coeff');\n",
+"Ds=poly(den,'s','coeff');\n",
+"G=syslin('c',Ns/Ds)\n",
+"\n",
+"//PID controller, Gc=(kd s^2 + kp s + ki)/s\n",
+"num=[ki kp kd;ki kp 0;0 kp 0]; //numerator parameters of controller)\n",
+" //(row wise for PID, PI and P)\n",
+"den=[0 1]; //denominator parameters of controller\n",
+"Ds=poly(den,'s','coeff'); //denominator polynomial of controller\n",
+"t=0:0.005:10; // Simulation time\n",
+"//------------------------------------------------------------------\n",
+"//Step disturbance response with P, PI and PID controller. \n",
+"\n",
+"for i=1:3\n",
+"Ns=poly(num(i,:),'s','coeff');//numerator polynomial of controller\n",
+"sysG=syslin('c',Ns/Ds);\n",
+"sysD=G/. sysG;\n",
+"v(i,:)=csim('step',t,sysD);\n",
+"end\n",
+"plot(t',v');\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script to set the figure properties\n",
+"title('Responses of P,PI and PID control to step disturbance...\n",
+" input','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"hl=legend(['PID','PI','P']);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Reference step response\n",
+"\n",
+"figure\n",
+"for i=1:3\n",
+"Ns=poly(num(i,:),'s','coeff');\n",
+"Gc=syslin('c',Ns/Ds);\n",
+"// Step reference response with P, PI and PID controller.\n",
+"sysR=G*Gc/(1+G*Gc);\n",
+"v(i,:)=csim('step',t,sysR);\n",
+"end\n",
+"plot(t',v')\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script to set the figure properties\n",
+"title('Responses of PID control to step reference input','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"hl=legend(['PID','PI','P']);\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.7: Discrete_Equivalent.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 4.7\n",
+"//Discrete Equivalent.\n",
+"//------------------------------------------------------------------\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"// Transfer function\n",
+"s=%s; \n",
+"num=[1 11];\n",
+"den=[1 3]\n",
+"Us=poly(num,'s','coeff');\n",
+"Es=poly(den,'s','coeff');\n",
+"Ds=syslin('c',Us/Es);\n",
+"sysc=tf2ss(Ds)\n",
+"\n",
+"//Discretize the system using sampling time Ts=1 and Bilinear Transform\n",
+"Ts=1;\n",
+"sysd=cls2dls(sysc,Ts);\n",
+"\n",
+"//Pulse transfer function\n",
+"Dd=ss2tf(sysd)\n",
+"disp(Dd,'Dd=')\n",
+"disp('Note that, multiply numerator and denomintor each by 7... \n",
+" will give the result as in book.')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.8: Equivalent_discrete_controller_for_DC_motor_speed_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 4.8\n",
+"//Equivalent discrete controller for DC motor speed control.\n",
+"//------------------------------------------------------------------\n",
+"//NOTE THAT-- The system response (continuous) to sampled control \n",
+"//input depends on \n",
+"//the sampling time set for continuous signal in SIMULATION.\n",
+"//In this example we consider sampling period of 0.009 sec \n",
+"//to represent continuous time signal.\n",
+"//------------------------------------------------------------------\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// Continuous time system and controller\n",
+"// System transfer function\n",
+"s=%s; \n",
+"num=[45 0];\n",
+"den=[45 14 1]\n",
+"Nms=poly(num,'s','coeff');\n",
+"Dns=poly(den,'s','coeff');\n",
+"Gp=syslin('c',Nms/Dns); //system transfer function\n",
+"// Controller\n",
+"numDa=[6 1];\n",
+"denDa=[0 1]\n",
+"Nms=poly(numDa,'s','coeff');\n",
+"Dns=poly(denDa,'s','coeff');\n",
+"sysD=syslin('c',1.4*Nms/Dns); //controller transfer function\n",
+"//Closed loop responses\n",
+"num=[1 0];\n",
+"den=[1 0];\n",
+"Nms=poly(num,'s','coeff');\n",
+"Dns=poly(den,'s','coeff');\n",
+"H=syslin('c',Nms/Dns)\n",
+"sysDa=Gp*sysD/.H;\n",
+"//step response and control input\n",
+"t=0:0.009:5;\n",
+"yt=csim('step',t,sysDa); //step response\n",
+"figure(0)\n",
+"plot2d(t,yt,1)\n",
+"Gu=sysD/(1+Gp*sysD);\n",
+"ut=csim('step',t,Gu); //control input\n",
+"figure(1)\n",
+"plot2d(t,ut,1)\n",
+"//------------------------------------------------------------------\n",
+"sys=tf2ss(Gp); //state space model of the system\n",
+"con=tf2ss(sysD); //controller state space model\n",
+"// discrete-time time system and controller\n",
+"//Discretize the system and control with sampling time Ts=0.07\n",
+"// using Bilinear Transform\n",
+"Ts=0.07;\n",
+"sysDd=cls2dls(sys,Ts); // discrete-time system state space model\n",
+"conDd=cls2dls(con,Ts); // discrete-time controller state space model\n",
+"//Pulse transfer function of system\n",
+"Gpz=ss2tf(sysDd);\n",
+"//Pulse transfer function of controller\n",
+"Gcz=ss2tf(conDd);\n",
+"//Closed loop response\n",
+"Gz=Gpz*Gcz/(1+Gpz*Gcz)\n",
+"//Control input pulse transfer function\n",
+"Guz=Gcz/(1+Gpz*Gcz)\n",
+"T=0:Ts:5;\n",
+"r=ones(1,length(T));\n",
+"yd=flts(r,Gz);............//Discrete respnse to discrete input\n",
+"ud=flts(r,Guz); //Discrete Control input\n",
+"//continuous response for digital input\n",
+"t=0:0.009:5;\n",
+"k=0;\n",
+"for i=1:length(yd)\n",
+" for j=1:8\n",
+" if (k+j)>length(t) then\n",
+" break\n",
+" else\n",
+" YD(1,k+j)=yd(i);\n",
+" end\n",
+" end\n",
+" k=k+j;\n",
+"end\n",
+"yt=csim(1-YD,t,Gp*sysD);\n",
+"scf(0)\n",
+"plot2d(t,yt,5);\n",
+"scf(1)\n",
+"plot2d2(T,ud,5);\n",
+"//------------------------------------------------------------------\n",
+"//Discretize the system and control with sampling time Ts=0.035\n",
+"// using Bilinear Transform\n",
+"Ts=0.035;\n",
+"sysDd=cls2dls(sys,Ts); // discrete-time system state space model\n",
+"conDd=cls2dls(con,Ts); // discrete-time controller state space model\n",
+"Gpz=ss2tf(sysDd); //Pulse transfer function of system\n",
+"Gcz=ss2tf(conDd); //Pulse transfer function of controller\n",
+"//Closed loop response\n",
+"Gz=Gpz*Gcz/(1+Gpz*Gcz)\n",
+"//Control input pulse transfer function\n",
+"Guz=Gcz/(1+Gpz*Gcz)\n",
+"T=0:Ts:5;\n",
+"r=ones(1,length(T));\n",
+"yd=flts(r,Gz);............//Discrete respnse to discrete input\n",
+"ud=flts(r,Guz); //Discrete Control input\n",
+"t=0:0.009:5;\n",
+"k=0;\n",
+"for i=1:length(yd)\n",
+" for j=1:4\n",
+" if (k+j)>length(t) then\n",
+" break\n",
+" else\n",
+" YD(1,k+j)=yd(i);\n",
+" end\n",
+" end\n",
+" k=k+j;\n",
+"end\n",
+"yt=csim(1-YD,t,Gp*sysD);\n",
+"scf(0)\n",
+"plot2d(t,yt,2);\n",
+"scf(1)\n",
+"plot2d2(T,ud,2);\n",
+"scf(0)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script to set the figure properties\n",
+"title('Comparision plots of Speed-control system with continuous...\n",
+" and discrete controllers','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"hl=legend(['Continuous time','Discrete-time, Ts=0.07 s'...\n",
+",'Discrete-time, Ts=0.035 s'],4);\n",
+"scf(1)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script to set the figure properties\n",
+"title('Comparision plots of Speed-control system with continuous...\n",
+" and discrete controllers','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"hl=legend(['Continuous time','Discrete-time, Ts=0.07 s',...\n",
+"'Discrete-time, Ts=0.035 s']);\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/5-The_Root_Locus_Design_method.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/5-The_Root_Locus_Design_method.ipynb
new file mode 100644
index 0000000..6811aed
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/5-The_Root_Locus_Design_method.ipynb
@@ -0,0 +1,845 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 5: The Root Locus Design method"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.10: Design_using_Lead_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.10\n",
+"//Design using Lead compensator.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"\n",
+"NumG=1;\n",
+"DenG=s*(s+1);\n",
+"NumD=(s+2);\n",
+"DenD=(s+10);\n",
+"\n",
+"G=NumG/DenG;\n",
+"D=NumD/DenD;\n",
+"\n",
+"L=G*D; //open loop transfer function\n",
+"\n",
+"figure(0)\n",
+"evans(L)\n",
+"sgrid(0.5,7,6);\n",
+"\n",
+"xstring(-2,4,'Damping=0.5',0,0)\n",
+"xstring(-7,4,'w=7',0,0)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus for lead design','fontsize',3)\n",
+"zoom_rect([-14 -8 4 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"// Unit step response\n",
+"//closed loop system\n",
+"K=70;\n",
+"sysc=K*L/(1+K*L);\n",
+"sysc=syslin('c',sysc);\n",
+"t=linspace(0,10,1000);\n",
+"y=csim('step',t,sysc);\n",
+"figure(1)\n",
+"plot(t,y);\n",
+"title('Step response for the system with lead compensator','fontsize',3)\n",
+"xlabel('Time (sec)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"set(gca(),'grid',[0.3 0.3])\n",
+"zoom_rect([0 0 1.8 1.4])\n",
+"exec .\fig_settings.sci;\n",
+"\n",
+"scf(0)\n",
+"pl=roots(DenG*DenD+K*NumG*NumD) //closed loop poles at K=70;\n",
+"plot(real(pl),imag(pl),'ro') //closed loop pole-locations at K=70;\n",
+"xstring(-5.8,6,'K=70',0,0)\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.11: A_second_Lead_compensation_Design.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.11\n",
+"//A second Lead compensation Design. \n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"\n",
+"NumG=1;\n",
+"DenG=s*(s+1);\n",
+"NumD=(s+5.4);\n",
+"DenD=(s+20);\n",
+"\n",
+"Gs=NumG/DenG;\n",
+"Ds=NumD/DenD;\n",
+"\n",
+"Ls=Gs*Ds; //open loop transfer function\n",
+"\n",
+"zr=roots(NumD*NumG); //open loop system zeros\n",
+"pl=roots(DenD*DenG); //open loop system poles\n",
+"pd=-3.5+3.5*sqrt(3)*%i; //desired pole\n",
+"\n",
+"//Construction for placing a specific point on the root locus.\n",
+"figure(0)\n",
+"plzr(Ls)\n",
+"plot(real(pd),imag(pd),'ro')\n",
+"xarrows([real(pl(1));real(pd)],[imag(pl(1));imag(pd)],0,2)\n",
+"xarrows([real(pl(2));real(pd)],[imag(pl(2));imag(pd)],0,2)\n",
+"xarrows([real(pl(3));real(pd)],[imag(pl(3));imag(pd)],0,2)\n",
+"xarrows([real(zr);real(pd)],[imag(zr);imag(pd)],0,6)\n",
+"xarrows([real(zr);-3],[0;0],0,6)\n",
+"xarc(-6.4,1,2,2,0,72.6*64)\n",
+"xset('font size',1.5);\n",
+"xstring(-4.7,0.5,'$\psi$')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Construction for placing a specific point on the root locus',...\n",
+"'fontsize',3)\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"//Root locus of system transfer function with controller\n",
+"figure(1)\n",
+"evans(Ls)\n",
+"sgrid(0.5,7,6)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Root locus for','$ L(s)=\frac {s+5.4}{s(s+1)(s+20)}$'],...\n",
+"'fontsize',3)\n",
+"zoom_rect([-20 -8 5 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"// Unit step response\n",
+"//closed loop system\n",
+"\n",
+"K=127; // from root locus gain is computed \n",
+"sysc=K*Ls/(1+K*Ls)\n",
+"sysc=syslin('c',sysc);\n",
+"t=linspace(0,10,1000);\n",
+"y=csim('step',t,sysc);\n",
+"figure(2)\n",
+"plot(t,y);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Step response for K=127', 'and',...\n",
+"'$ L(s)=\frac {s+5.4}{s(s+1)(s+20)}$']...\n",
+",'fontsize',3)\n",
+"xlabel('Time (sec)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"zoom_rect([0 0 1.8 1.4])\n",
+"\n",
+"pl=roots(DenG*DenD+K*NumG*NumD) //closed loop poles at K=127;\n",
+"scf(1)\n",
+"plot(real(pl),imag(pl),'ro') //closed loop pole-locations at K=127;\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.12: Negative_root_Locus_for_an_Airplane.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.12\n",
+"//Negative root Locus for an Airplane.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"Ls=-(s-6)/(s*(s^2+4*s+13));\n",
+"evans(Ls)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Negative root locus for','$L(s)=\frac{s-6}{s(s^2+4s+13)}$'],...\n",
+"'fontsize',3)\n",
+"zoom_rect([-5 -6 10 6])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.1: Root_locus_of_a_Motor_Position_Control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.1\n",
+"//Root locus of a Motor Position Control.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"Ls=1/(s*(s+1));\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"evans(Ls)\n",
+"title(['Root locus for', '$L(s)=1/[s(s+1)]$'],'fontsize',3)\n",
+"zoom_rect([-2 -1.5 2 1.5])\n",
+"sgrid([0.5],1,5)\n",
+"xset('font',1,1.5) \n",
+"xstring(-1.2,1.1,'$\theta=sin^{-1} \xi$',0,0)\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.2: Root_locus_with_respect_to_a_plant_open_loop_pole.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.2\n",
+"//Root locus with respect to a plant open loop pole.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"s=poly(0,'s');\n",
+"Gs=s/(s*s+1);\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"evans(Gs,100)\n",
+"title(['Root locus vs. damping factor','$c$',...\n",
+"'for','$1+G(s)=1+1/[s(s+c)]=0$'],'fontsize',3)\n",
+"zoom_rect([-2 -1.5 2 1.5])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.3: Root_locus_for_satellite_attitude_control_with_PD_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.3\n",
+"//Root locus for satellite attitude control with PD control.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"sysS=(s+1)/(s^2);\n",
+"evans(sysS,100)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Root locus for','$L(s)=G(s)=(s+1)/s^2$'],'fontsize',3)\n",
+"zoom_rect([-6 -3 2 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.4: EX5_4.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.4\n",
+"//Root locus for satellite attitude control with modified \n",
+"//PD control or Lead compensator.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"sysL=(s+1)/(s^2*(s+12));\n",
+"evans(sysL,100)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Root locus for', '$L(s)=(s+1)/s^2(s+12)$'],'fontsize',3)\n",
+"zoom_rect([-6 -3 2 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.5: Root_locus_for_satellite_control_with_Lead_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.5\n",
+"//Root locus for satellite control with Lead compensator.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"sysL=(s+1)/(s^2*(s+4));\n",
+"evans(sysL)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Root locus for', '$L(s)=(s+1)/s^2(s+4)$'],'fontsize',3)\n",
+"zoom_rect([-6 -3 2 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.6: Root_locus_for_satellite_attitude_control_with_a_Transition_value_for_the_pole.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.6\n",
+"//Root locus for satellite attitude control with a \n",
+"//Transition value for the pole.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"sysL=(s+1)/(s^2*(s+9));\n",
+"evans(sysL)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Root locus for', '$L(s)=(s+1)/(s^2(s+9))$'],'fontsize',3)\n",
+"zoom_rect([-6 -3 2 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.7: Root_locus_for_satellite_control_with_a_Collocated_Flexibility.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.7\n",
+"//Root locus for satellite control with a Collocated Flexibility. \n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function with controller.\n",
+"\n",
+"s=poly(0,'s');\n",
+"NumD=(s+1);\n",
+"DenD=(s+12);\n",
+"D=NumD/DenD;\n",
+"\n",
+"NumG=(s+0.1)^2+36\n",
+"DenG=s^2*((s+0.1)^2+(6.6)^2)\n",
+"\n",
+"G=NumG/DenG;\n",
+"\n",
+"NumL=NumD*NumG;\n",
+"DenL=DenD*DenG;\n",
+"\n",
+"L=NumL/DenL;\n",
+"\n",
+"zr=roots(NumL);\n",
+"pl=roots(DenL);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Angle of departure.\n",
+"//Find angle of departure from pole at phi1= - 0.1 + 6.6i\n",
+"//(real poles don't have angle of departure,\n",
+"//they move along real axis only) \n",
+"//psi1=angle[(Departing pole)- (zero at - 0.1 + 6.6i)]\n",
+"[Mpsi1, psi1] = polar(pl(2)-zr(1))\n",
+"psi1=real(psi1)*180/%pi; //angle in degree\n",
+"\n",
+"//psi2=angle[(Departing pole)- (zero at - 0.1 - 6.6i)]\n",
+"[Mpsi2, psi2] = polar(pl(2)-zr(2)) \n",
+"psi2=real(psi2)*180/%pi; //angle in degree\n",
+"\n",
+"//psi3=angle[(Departing pole)- (zero at - 1)]\n",
+"[Mpsi3, psi3] = polar(pl(2)-zr(3)) \n",
+"psi3=real(psi3)*180/%pi; //angle in degree\n",
+"\n",
+"//phi2=angle[(Departing pole)- (pole at 0)]\n",
+"[Mphi2, phi2] = polar(pl(2)-pl(4)) \n",
+"phi2=real(phi2)*180/%pi; //angle in degree\n",
+"\n",
+"//phi3 is same as phi2, as pole is repeated at 0.\n",
+"phi3=phi2; \n",
+"\n",
+"//phi4=angle[(Departing pole)-(pole at - 0.1 - 6.6i )]\n",
+"[Mphi4, phi4] = polar(pl(2)-pl(3)) \n",
+"phi4=real(phi4)*180/%pi; //angle in degree\n",
+"\n",
+"//phi5=angle[(Departing pole)- (pole at - 12 )]\n",
+"[Mphi5, phi5] = polar(pl(2)-pl(1))\n",
+"phi5=real(phi5)*180/%pi; //angle in degree\n",
+"\n",
+"//Therefore angle of departure phi1 at - 0.1 + 6.6i is\n",
+"//phi1 = 180 + sum(angle to zeros) - sum(angle to poles)\n",
+"\n",
+"phi1 = 180 + sum(psi1+psi2+psi3) - sum(phi2+phi3+phi4+phi5)\n",
+"\n",
+"//angle contributions in figure \n",
+"figure(0)\n",
+"plzr(L)\n",
+"xset('font size',1.5)\n",
+"xarrows([real(pl(1));real(pl(2))],[imag(pl(1));imag(pl(2))],0,2)\n",
+"xarc(-13,1,2,2,0,phi5*64)\n",
+"xstring(-11,0.05,'$\phi_5$')\n",
+"\n",
+"\n",
+"xarrows([real(zr(3));real(pl(2))],[imag(zr(3));imag(pl(2))],0,4)\n",
+"xarc(-2,1,2,2,0,psi3*64)\n",
+"xstring(-0.7,1,'$\psi_3$')\n",
+"\n",
+"xarrows([real(pl(4));real(pl(2))],[imag(pl(4));imag(pl(2))],0,5)\n",
+"xarc(-1,1,2,2,0,phi2*64)\n",
+"xstring(0.8,0.5,'$\phi_2,\,\phi_3$')\n",
+"\n",
+"\n",
+"xarrows([real(pl(3));real(pl(2))],[imag(pl(3));imag(pl(2))],0,3)\n",
+"xarc(-1,-6.6,2,2,0,phi4*64)\n",
+"xstring(0.8,-7,'$\phi_4$')\n",
+"\n",
+"xarrows([real(zr(2));real(pl(2))],[imag(zr(2));imag(pl(2))],0,6)\n",
+"xarc(-1,-5,2,2,0,psi2*64)\n",
+"xstring(0.8,-5.5,'$\psi_2$')\n",
+"\n",
+"xarrows([real(zr(1));real(pl(2))],[imag(zr(1));imag(pl(2))],0,24)\n",
+"xstring(0.3,5.5,'$\psi_1$')\n",
+"xstring(0.3,6.5,'$\phi_1$')\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Figure for computing a departure angle for',...\n",
+"'$L(s)=\frac{s+1}{s+12}\frac{(s+0.1)^2+6^2}{s^2[(s+0.1)^2+6.6^2]}$'],...\n",
+"'fontsize',3)\n",
+"zoom_rect([-15 -8 5 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Root locus system transfer function with controller.\n",
+"figure(1)\n",
+"evans(L)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Root locus for','$L(s)=\frac{s+1}{s+12}\frac{(s+0.1)^2+6^2}...\n",
+"{s^2[(s+0.1)^2+6.6^2]}$'],'fontsize',3)\n",
+"zoom_rect([-15 -8 5 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.8: Root_locus_for_noncollocated_case.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.8\n",
+"//Root locus for noncollocated case.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function with controller \n",
+"\n",
+"s=poly(0,'s');\n",
+"NumD=(s+1);\n",
+"DenD=(s+12);\n",
+"sysD=NumD/DenD;\n",
+"\n",
+"NumG=1\n",
+"DenG=s^2*((s+0.1)^2+(6.6)^2)\n",
+"\n",
+"sysG=NumG/DenG;\n",
+"\n",
+"NumL=NumD*NumG;\n",
+"DenL=DenD*DenG;\n",
+"\n",
+"sysL=NumL/DenL;\n",
+"\n",
+"zr=roots(NumL);\n",
+"pl=roots(DenL);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Angle of departure.\n",
+"//Find angle of departure from pole at phi1= - 0.1 + 6.6i\n",
+"//(real poles don't have angle of departure,\n",
+"//they move along real axis only) \n",
+"\n",
+"//psi1=angle[(Departing pole)- (zero at - 1]\n",
+"[Mpsi1, psi1] = polar(pl(2)-zr(1)) \n",
+"psi1=real(psi1)*180/%pi; //angle in degree\n",
+"\n",
+"//phi2=angle[(Departing pole)- (pole at 0)]\n",
+"[Mphi2, phi2] = polar(pl(2)-pl(4)) \n",
+"phi2=real(phi2)*180/%pi; //angle in degree\n",
+"\n",
+"//phi3 is same as phi2, as pole is repeated at 0.\n",
+"phi3=phi2; \n",
+"\n",
+"//phi4=angle[(Departing pole)-(pole at - 0.1 - 6.6i )]\n",
+"[Mphi4, phi4] = polar(pl(2)-pl(3)) \n",
+"phi4=real(phi4)*180/%pi; //angle in degree\n",
+"\n",
+"//phi5=angle[(Departing pole)- (pole at - 12 )]\n",
+"[Mphi5, phi5] = polar(pl(2)-pl(1)) \n",
+"phi5=real(phi5)*180/%pi; //angle in degree\n",
+"\n",
+"//Therefore angle of departure phi1 at - 0.1 + 6.6i is\n",
+"//phi1 = 180 + sum(angle to zeros) - sum(angle to poles)\n",
+"\n",
+"phi1 = 180 + sum(psi1) - sum(phi2+phi3+phi4+phi5)\n",
+"\n",
+"//angle contributions in figure \n",
+"figure(0)\n",
+"plzr(sysL)\n",
+"xset('font size',1.5)\n",
+"xarrows([real(pl(1));real(pl(2))],[imag(pl(1));imag(pl(2))],0,2)\n",
+"xarrows([real(pl(1)); -10],[0;0],0,2)\n",
+"xarc(-13,1,2,2,0,phi5*64)\n",
+"xstring(-11,0.05,'$\phi_5$')\n",
+"\n",
+"xarrows([real(zr(1));real(pl(2))],[imag(zr(1));imag(pl(2))],0,6)\n",
+"xarrows([real(zr(1)); -0.3],[0;0],0,6)\n",
+"xarc(-2,1,2,2,0,psi1*64)\n",
+"xstring(-0.7,1,'$\psi_1$')\n",
+"\n",
+"xarrows([real(pl(4));real(pl(2))],[imag(pl(4));imag(pl(2))],0,5)\n",
+"xarrows([real(pl(4)); 1],[0;0],0,5)\n",
+"xarc(-1,1,2,2,0,phi2*64)\n",
+"xstring(0.8,0.5,'$\phi_2,\,\phi_3$')\n",
+"\n",
+"xarrows([real(pl(3));real(pl(2))],[imag(pl(3));imag(pl(2))],0,17)\n",
+"xarrows([real(pl(3)); 2],[imag(pl(3));imag(pl(3))],0,17)\n",
+"xarc(-1.1,-5.6,2,2,0,phi4*64)\n",
+"xstring(0.8,-5.5,'$\phi_4$')\n",
+"\n",
+"xstring(0.3,6.5,'$\phi_1$')\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Figure to compute a departure angle for',...\n",
+"'$L(s)=\frac{s+1}{s+12}\frac{1}{s^2[(s+0.1)^2+6.6^2]}$'],...\n",
+"'fontsize',3)\n",
+"zoom_rect([-15 -8 5 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Root locus of system transfer function with controller\n",
+"figure(1)\n",
+"evans(sysL)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Root locus for','$L(s)=\frac{s+1}{s+12}\frac{1}...\n",
+"{s^2[(s+0.1)^2+6.6^2]}$'],'fontsize',3)\n",
+"zoom_rect([-15 -8 5 8])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5.9: Root_locus_for_the_system_having_complex_multiple_roots.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 5.9\n",
+"//Root locus for the system having complex multiple roots.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function\n",
+"\n",
+"s=poly(0,'s');\n",
+"\n",
+"NumL=1;\n",
+"DenL=s*(s+2)*[(s+1)^2+4];\n",
+"\n",
+"L=NumL/DenL;\n",
+"\n",
+"zr=roots(NumL);\n",
+"pl=roots(DenL);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Angle of departure.\n",
+"//Find angle of departure from pole at phi1= - 1 + 2i\n",
+"//(real poles don't have angle of departure,\n",
+"// they move along real axis only) \n",
+"\n",
+"//phi2=angle[(Departing pole)- (pole at 0)]\n",
+"[Mphi1, phi1] = polar(pl(1)-pl(4)) \n",
+"phi1=real(phi1)*180/%pi; //angle in degree\n",
+"\n",
+"//phi2=angle[(Departing pole)- (pole at -2)]\n",
+"[Mphi2, phi2] = polar(pl(1)-pl(3)) \n",
+"phi2=real(phi2)*180/%pi; //angle in degree\n",
+"\n",
+"//phi2=angle[(Departing pole)- (pole at - 1 - 2i)]\n",
+"[Mphi4, phi4] = polar(pl(1)-pl(2))\n",
+"phi4=real(phi4)*180/%pi; //angle in degree\n",
+"\n",
+"//Therefore angle of departure phi1 at - 1 + 2i is\n",
+"//phi3 = 180 + sum(angle to zeros) - sum(angle to poles)\n",
+"\n",
+"phi3 = 180 - sum(phi1+phi2+phi4)\n",
+"\n",
+"//angle contributions in figure \n",
+"figure(0)\n",
+"plzr(L)\n",
+"xset('font size',1.5)\n",
+"xarrows([real(pl(4));real(pl(1))],[imag(pl(4));imag(pl(1))],0,2)\n",
+"xarrows([real(pl(4)); 1],[0;0],0,2)\n",
+"xarc(-0.5,0.5,1,1,0,phi1*64)\n",
+"xstring(0.5,0.25,'$\phi_1$')\n",
+"\n",
+"xarrows([real(pl(3));real(pl(1))],[imag(pl(3));imag(pl(1))],0,5)\n",
+"xarrows([real(pl(3)); -1.3],[0;0],0,5)\n",
+"xarc(-2.5,0.5,1,1,0,phi2*64)\n",
+"xstring(-1.5,0.25,'$\phi_2$')\n",
+"\n",
+"xarrows([real(pl(2));real(pl(1))],[imag(pl(2));imag(pl(1))],0,17)\n",
+"xarrows([real(pl(2)); -0.3],[-2;-2],0,17)\n",
+"xarc(-1.5,-1.5,1,1,0,phi4*64)\n",
+"xstring(-0.5,-1.7,'$\phi_4$')\n",
+"\n",
+"xstring(-0.8,2,'$\phi_1$')\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Figure to computing a departure angle for',...\n",
+"'$L(s)=\frac{1}{s(s+2)[(s+1)^2+4]}$'],'fontsize',3)\n",
+"zoom_rect([-4 -3 4 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"//Root locus of system transfer function with controller\n",
+"figure(1)\n",
+"evans(L)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Root locus for','$L(s)=\frac{1}{s(s+2)[(s+1)^2+4]}$']...\n",
+",'fontsize',3)\n",
+"zoom_rect([-4 -3 4 3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/6-The_Frequency_Response_Design_Method.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/6-The_Frequency_Response_Design_Method.ipynb
new file mode 100644
index 0000000..ba86f94
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/6-The_Frequency_Response_Design_Method.ipynb
@@ -0,0 +1,1164 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 6: The Frequency Response Design Method"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.10: Nyquist_plot_for_an_Open_loop_unstable_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.10\n",
+"// Nyquist plot for an Open-loop unstable system.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"sysG=(s+1)/(s*(s/10-1));\n",
+"evans(sysG,50)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Root Locus for','$G(s)=(s+1)/[s(s/10-1)]$'],'fontsize',3)\n",
+"zoom_rect([-5 -4 5 4])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"g1=syslin('c',(s+1)/(s*(s/10-1)));\n",
+"//------------------------------------------------------------------\n",
+"//The bode plot of the system\n",
+"figure;\n",
+"bode(g1,0.1/2/%pi,100/2/%pi,'rad')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Bode plot for','$G(s)=(s+1)/[s(s/10-1)]$'],'fontsize',3)\n",
+"//bode(g,2*%pi*0.1,2*%pi*100)\n",
+"//------------------------------------------------------------------\n",
+"figure;\n",
+"//The nyquist plot of the system\n",
+"nyquist(g1,0.5/2/%pi,100/2/%pi,0.05)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Nyquist plot for','$G(s)=(s+1)/[s(s/10-1)]$'],'fontsize',3)\n",
+"f=gca();\n",
+"f.x_location = 'origin';\n",
+"f.y_location = 'origin';\n",
+"zoom_rect([-2 -2 1 2]);\n",
+"xset('color',2);\n",
+"xset('font size', 3);\n",
+"xstring(-1,1.5,'${\fgcolor{blue}{\omega>0}}$',0,0);\n",
+"xstring(-1,-1.5,'${\fgcolor{blue}{\omega<0}}$',0,0);\n",
+"xstring(-1.5,0,'${\fgcolor{blue}{\omega=\pm \sqrt{10}}}$',0,0);\n",
+"xstring(-0.5,0.1,'${\fgcolor{blue}{\omega=\infty}}$',0,0);\n",
+"xarrows([-0.2;0],[0.2;0],-1,2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.11: Stability_properties_for_a_conditionally_stable_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.11\n",
+"// Stability properties for a conditionally stable system.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"Gs=(s+10)^2/(s^3);\n",
+"evans(Gs,100)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([-40 -20 5 20])\n",
+"title(['Root locus for','$G(s)=(s+10)^2/s^3$'],'fontsize',3)\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"Gs1=syslin('c',(s+10)^2/(s^3));\n",
+"//------------------------------------------------------------------\n",
+"//The nyquist plot of the system\n",
+"figure;\n",
+"nyquist(7*Gs1,8/2/%pi,100/2/%pi,0.005)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Nyquist plot for','$G(s)=(s+10)^2/s^3$'],'fontsize',3)\n",
+"f=gca();\n",
+"f.x_location = 'origin';\n",
+"f.y_location = 'origin';\n",
+"xset('color',2);\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.12: Nyquist_plot_for_a_system_with_Multiple_Crossover_frequencies.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.12\n",
+"// Nyquist plot for a system with Multiple Crossover frequencies\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"K=85;\n",
+"g1=K*(s+1)/(s^2*(s^2+2*s+82));\n",
+"g2=(s^2+2*s+43.25)/(s^2+2*s+101);\n",
+"\n",
+"Gs=syslin('c',g2*g1);\n",
+"//------------------------------------------------------------------\n",
+"figure;\n",
+"//The nyquist plot of the system\n",
+"nyquist(Gs,0.5/2/%pi,100/2/%pi,0.005)\n",
+"title(['Nyquist plot for the complex system';...\n",
+"'$G(s)=85(s+1)(s^2+2s+43.25)/[((s^2+2s+82)(s^2+2s+101)]$'],...\n",
+"'fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([-2 -1 0.6 1])\n",
+"f=gca();\n",
+"f.x_location = 'origin';\n",
+"f.y_location = 'origin';\n",
+"xset('color',2);\n",
+"//------------------------------------------------------------------\n",
+"//The bode plot of the system\n",
+"gm=g_margin(Gs);\n",
+"pm=p_margin(Gs)\n",
+"disp(pm,'Phase margin',gm,'Gain margin')\n",
+"figure(1)\n",
+"bode(Gs,0.01/2/%pi,100/2/%pi,0.01)\n",
+"title(['Bode plot for';...\n",
+"'$G(s)=85(s+1)(s^2+2s+43.25)/[((s^2+2s+82)(s^2+2s+101)]$'],...\n",
+"'fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.13: Use_of_simple_design_criterion_for_spacecraft_attitude_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.13\n",
+"// Use of simple design criterion for spacecraft attitude control.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"G=1/s^2;\n",
+"g1=syslin('c',G);\n",
+"\n",
+"//The bode plot of the system\n",
+"zoom_rect([0.01 -20 100 60])\n",
+"bode(g1,0.05/2/%pi,2/2/%pi,'rad')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Magnitude of the spacecrafts frequency','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"K=1;\n",
+"Td=20;\n",
+"Ds=(Td*s+1);\n",
+"gd1=syslin('c',K*Ds*G);\n",
+"\n",
+"////The bode plot of compnenstaed open loop system\n",
+"figure\n",
+"bode(gd1,0.01/2/%pi,1/2/%pi,'rad')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Bode plot for compensated open-loop transfer function'...\n",
+",'fontsize',3)\n",
+"xstring(0.02,70,'-40db/decade',0,0);\n",
+"xstring(0.2,40,'-20db/decade',0,0);\n",
+"\n",
+"//The bode plot of compnenstaed closed loop system\n",
+"K=0.01;\n",
+"gc1=K*gd1/(1+K*gd1);\n",
+"gcl1=syslin('c',gc1);\n",
+"figure\n",
+"bode(gcl1,0.01/2/%pi,10/2/%pi,'rad')\n",
+"title('Closesd loop frequency response','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"\n",
+"//Bandwidth\n",
+"[frq, repf,splitf]=repfreq(gc1,[0.01/2/%pi:0.001:10/2/%pi]);\n",
+"[db, phi]=dbphi(repf);\n",
+"w=find(db<=db(1)-3);\n",
+"wc=w(1);\n",
+"frqc=frq(wc)*2*%pi;\n",
+"\n",
+"plot2d3(frqc,db(wc),5)\n",
+"\n",
+"[r c]=size(frq(1:w(1)));\n",
+"magn=db(wc)*ones(r,c)\n",
+"plot(frq(1:w(1))*2*%pi,magn,'b--')\n",
+"temp_db=db(w);\n",
+"[r c]=size(db(w));\n",
+"temp_w=frqc*ones(r,c);\n",
+"plot(temp_w,temp_db,'b--')\n",
+"xset('font size', 3);\n",
+"xstring(0.04,-16,'$\omega_{BW}$');\n",
+"xstring(frqc,-4,'-3db');\n",
+"xset('line style',4)\n",
+"xarrows([0.01;frqc],[-10;-10],-0.2,5)\n",
+"xarrows([frqc;0.01],[-10;-10],-0.2,5)\n",
+"//------------------------------------------------------------------\n",
+"//Step response of PD compnensation\n",
+"figure\n",
+"t=0:0.5:100;\n",
+"v=csim('step',t,gcl1);\n",
+"plot2d(t,v)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Step response for PD compensation','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('$\theta$','fontsize',2)\n",
+"//-------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.14: Lead_compensation_for_DC_motor.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.14 \n",
+"//Lead compensation for DC motor.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"g=1/s/(s+1);\n",
+"K=10; //DC gain\n",
+"KGs=syslin('c',K*g);\n",
+"//Lead compensator\n",
+"numD=s/2+1;\n",
+"denD=s/10+1;\n",
+"D=numD/denD;\n",
+"Ds=syslin('c',D);\n",
+"KGDs=Ds*KGs; //compensated system\n",
+"//------------------------------------------------------------------\n",
+"//(a) The bode plot of the system\n",
+"bode([KGs;KGDs],0.1/2/%pi,100/2/%pi,['KG(s)';'D(s)G(s)'],'rad');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Frequency response of lead compensation design','fontsize',3)\n",
+"//root locus\n",
+"figure(1)\n",
+"evans(KGDs/K)\n",
+"xset('font size', 3);\n",
+"xstring(-10,4,'$KD(s)=\frac{s/2+1}{s/10+1}$',0,0)\n",
+"xstring(-10,2,'$G(s)=\frac{1}{s(s+1)}$',0,0)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus for lead compensation design','fontsize',3)\n",
+"zoom_rect([-14 -8 4 8])\n",
+"f=gca();\n",
+"f.x_location = 'origin';\n",
+"f.y_location = 'origin';\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"//(b) digital version of lead compensator\n",
+"//Discretize the system using sampling time Ts=0.05 and Bilinear Transform\n",
+"Ts=0.05; //in book its 0.005, which may not give expected responses\n",
+"D=tf2ss(KGDs/K/g);\n",
+"sysD=cls2dls(D,Ts);\n",
+"//Pulse transfer function\n",
+"Ddz=ss2tf(sysD)\n",
+"disp(Ddz,'Ddz=')\n",
+"//------------------------------------------------------------------\n",
+"//(c) Compare step and ramp responses.\n",
+"//step response switch sw=1 and for ramp response sw=0\n",
+"//------------------------------------------------------------------\n",
+"//step response\n",
+"sw=1; \n",
+"importXcosDiagram('.\Ex6_14_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"figure,\n",
+"a1=newaxes(); \n",
+"a1.axes_bounds=[0,0,1.0,0.5];\n",
+"plot(time_resp.time,time_resp.values)\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"title(['Lead-compensation design (a) step Response...\n",
+" (b) ramp response'],'fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller',4)\n",
+"//------------------------------------------------------------------\n",
+"//ramp response\n",
+"sw=0; \n",
+"importXcosDiagram('.\Ex6_14_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"a2=newaxes(); \n",
+"a2.axes_bounds=[0,0.5,1.0,0.5];\n",
+"plot(time_resp.time,time_resp.values)\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"title('(b)','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller',4)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.15: Lead_compensation_for_Temperature_Control_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.15\n",
+"//Lead compensation for Temperature Control System.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"numG=1;\n",
+"denG=(s/0.5+1)*(s+1)*(s/2+1);\n",
+"sysG=numG/denG;\n",
+"//Dc gain\n",
+"K=9;\n",
+"KGs=syslin('c',K*sysG);\n",
+"//Lead compensator 1\n",
+"numD=s+1;\n",
+"denD=s/3+1;\n",
+"D1=numD/denD;\n",
+"D1s=syslin('c',D1);\n",
+"KGD1s=D1s*KGs; //compensated system\n",
+"//Lead compensator 2\n",
+"numD=s/1.5+1;\n",
+"denD=s/15+1;\n",
+"D2=numD/denD;\n",
+"D2s=syslin('c',D2);\n",
+"KGD2s=D2s*KGs; //compensated system\n",
+"//The bode plot of the system with K\n",
+"bode([KGs;KGD1s;KGD2s],0.1/2/%pi,10/2/%pi,['KG';'KGD1';'KGD2'],'rad');\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Bode plot for lead compensation design','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"//Margins of uncompensated and compensated systems\n",
+"[gm1,wcg1]=g_margin(KGs);\n",
+"[pm1,wcp1]=p_margin(KGs);\n",
+"disp(wcp1*2*%pi,'Wcp',wcg1*2*%pi,'Wcg',pm1,...\n",
+"'Phase margin',gm1,'Gain margin',...\n",
+"'Uncompensated system :')\n",
+"[gm2,wcg2]=g_margin(KGD1s);\n",
+"[pm2,wcp2]=p_margin(KGD1s);\n",
+"disp(wcp2*2*%pi,'Wcp',wcg2*2*%pi,'Wcg',pm2,...\n",
+"'Phase margin',gm2,'Gain margin',...\n",
+"'System with D1 compensator :')\n",
+"[gm3,wcg3]=g_margin(KGD2s);\n",
+"[pm3,wcp3]=p_margin(KGD2s);\n",
+"disp(wcp3*2*%pi,'Wcp',wcg3*2*%pi,'Wcg',pm3,...\n",
+"'Phase margin',gm3,'Gain margin',...\n",
+"'System with D2 compensator :')\n",
+"//------------------------------------------------------------------\n",
+"//step response comparison\n",
+"//closed loop system\n",
+"Gc1=KGD1s/(KGD1s+1);\n",
+"Gc2=KGD2s/(KGD2s+1);\n",
+"figure;\n",
+"t=0:0.05:20;\n",
+"v1=csim('step',t,Gc1);\n",
+"v2=csim('step',t,Gc2);\n",
+"plot2d([t',t'],[v1',v2'])\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Step response for lead compensation design','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('y','fontsize',2)\n",
+"xset('font size', 3);\n",
+"xarrows([2.5;1.5],[1.3;1.2],-1,1)\n",
+"xstring(2.5,1.3,'D2',0,0)\n",
+"xstring(4,1.2,'D1',0,0)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.16: Lead_compensation_for_Servomechanism_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.16\n",
+"//Lead compensation for Servomechanism System.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"numG=10;\n",
+"denG=s*(s/2.5+1)*(s/6+1);\n",
+"G=numG/denG;\n",
+"//Dc gain\n",
+"K=1;\n",
+"KGs=syslin('c',K*G);\n",
+"//Lead compensator 1\n",
+"numD=s/2+1;\n",
+"denD=s/20+1;\n",
+"D1=numD/denD;\n",
+"D1s=syslin('c',D1);\n",
+"KGD1s=D1s*KGs; //compensated system\n",
+"//Lead compensator 2\n",
+"numD=s/4+1;\n",
+"denD=s/40+1;\n",
+"D2=D1*numD/denD; //double compensator\n",
+"D2s=syslin('c',D2);\n",
+"KGD2s=D2s*KGs; //compensated system\n",
+"//The bode plot of the system with K\n",
+"bode([KGs;KGD1s;KGD2s],0.1/2/%pi,100/2/%pi,['KG';'KGD1';'KGD2'],'rad');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Bode plot for lead compensation design','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"//Margins of uncompensated and compensated systems\n",
+"[gm1,wcg1]=g_margin(KGs);\n",
+"[pm1,wcp1]=p_margin(KGs);\n",
+"disp(wcp1*2*%pi,'Wcp',wcg1*2*%pi,'Wcg',pm1,...\n",
+"'Phase margin',gm1,'Gain margin','Uncompensated system :')\n",
+"[gm2,wcg2]=g_margin(KGD1s);\n",
+"[pm2,wcp2]=p_margin(KGD1s);\n",
+"disp(wcp2*2*%pi,'Wcp',wcg2*2*%pi,'Wcg',pm2,...\n",
+"'Phase margin',gm2,'Gain margin','System with D1 compensator :')\n",
+"[gm3,wcg3]=g_margin(KGD2s);\n",
+"[pm3,wcp3]=p_margin(KGD2s);\n",
+"disp(wcp3*2*%pi,'Wcp',wcg3*2*%pi,'Wcg',pm3,...\n",
+"'Phase margin',gm3,'Gain margin','System with D2 compensator :')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.17: Lag_compensation_for_Temperature_Control_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.17\n",
+"//Lag compensation for Temperature Control System.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"numG=1;\n",
+"denG=(s/0.5+1)*(s+1)*(s/2+1);\n",
+"G=numG/denG;\n",
+"//Dc gain\n",
+"K=3; //to set phase requirement\n",
+"KGs=syslin('c',K*G);\n",
+"//Lag compensator\n",
+"numD=5*s+1;\n",
+"denD=15*s+1;\n",
+"D=3*numD/denD;\n",
+"Ds=syslin('c',D);\n",
+"KGDs=Ds*KGs; //compensated system\n",
+"//The bode plot of the system with K\n",
+"bode([KGs;KGDs],0.01/2/%pi,10/2/%pi,['KG';'KGD'],'rad');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Frequency response of lag-compensation design','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"//Margins of uncompensated and compensated systems\n",
+"[gm1,wcg1]=g_margin(KGs);\n",
+"[pm1,wcp1]=p_margin(KGs);\n",
+"disp(wcp1*2*%pi,'Wcp',wcg1*2*%pi,'Wcg',pm1,'Phase margin',...\n",
+"gm1,'Gain margin','Uncompensated system :')\n",
+"[gm2,wcg2]=g_margin(KGDs);\n",
+"[pm2,wcp2]=p_margin(KGDs);\n",
+"disp(wcp2*2*%pi,'Wcp',wcg2*2*%pi,'Wcg',pm2,'Phase margin',...\n",
+"gm2,'Gain margin','Compensated system :')\n",
+"//------------------------------------------------------------------\n",
+"//step response\n",
+"//closed loop system\n",
+"Gc=KGDs/(KGDs+1);\n",
+"figure;\n",
+"t=0:0.05:20;\n",
+"v=csim('step',t,Gc);\n",
+"plot2d(t,v)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Step response for lag compensation design','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('y','fontsize',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.18: Lag_compensation_for_DC_motor.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.18\n",
+"//Lag compensation for DC motor.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"g=1/s/(s+1);\n",
+"K=10; //DC gain\n",
+"KGs=syslin('c',K*g);\n",
+"//Lag compensator\n",
+"numD=10*s+1; //0.1 \n",
+"denD=100*s+1; //0.01\n",
+"D=numD/denD;\n",
+"Ds=syslin('c',D);\n",
+"KGDs=Ds*KGs; //compensated system\n",
+"//The bode plot of the system\n",
+"bode([KGs;KGDs],0.001/2/%pi,10/2/%pi,['KG(s)';'D(s)G(s)'],'rad');\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Frequency response of lag-compensation design...\n",
+" of DC motor','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"//step response\n",
+"//closed loop system\n",
+"Gc=KGDs/(KGDs+1);\n",
+"figure;\n",
+"t=0:0.05:50;\n",
+"v=csim('step',t,Gc);\n",
+"plot(t,v,2)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Step response for Lag-compensation design...\n",
+" of DC motor','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('y','fontsize',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.19: PID_compensation_design_for_spacecraft_attitude_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.19\n",
+"//PID compensation design for spacecraft attitude control.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"G1=(0.9/s^2);\n",
+"G2=(2/(s+2));\n",
+"G=G1*G2;\n",
+"Gs=syslin('c',G);\n",
+"// PID controller parameters\n",
+"Td_inv=0.1; // Td_inv=1/Td=0.1\n",
+"Kd=1/Td_inv; //Kd=Td=Td_inv (derivative gain)\n",
+"Ti_inv=0.005; // Ti_inv=1/Ti=0.005\n",
+"Ki=Ti_inv; //Ki=Ti_inv (integral gain)\n",
+"Kp=0.05 //Kp (Proportional gain)\n",
+"D=Kp*(Kd*s+1)*(Ki/s+1); //PID Compensator\n",
+"Dsc=syslin('c',D);\n",
+"Ds=syslin('c',D/Kp); //PID Compensator with Kp=1 \n",
+"// Compensated system with Kp=1\n",
+"GDs=Gs*Ds;\n",
+"//PID compensated system Kp=0.05;\n",
+"GDsc=Gs*Dsc;\n",
+"//------------------------------------------------------------------\n",
+"//The bode plots\n",
+"bode([Gs;GDs;GDsc],0.01/2/%pi,100/2/%pi,...\n",
+"['G(s)';'D(s)G(s) with (Kp=1)';'D(s)G(s) with (Kp=0.05)'],'rad');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Compensation for PID design','fontsize',3)\n",
+"//Phase margin of pid compensated system with Kp=0.05;\n",
+"[pm wcp]=p_margin(GDsc);\n",
+"//------------------------------------------------------------------\n",
+"//closed loop system\n",
+"//step response\n",
+"Gc=GDsc/(GDsc+1);\n",
+"figure;\n",
+"t=0:0.05:40;\n",
+"y=csim('step',t,Gc);\n",
+"plot(t,y,2)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Step response for PID compensation of spacecraft'...\n",
+",'fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('$theta$','fontsize',2)\n",
+"//------------------------------------------------------------------\n",
+"//step disturbance response\n",
+"Gc=G1/((G1*G2*D)+1);\n",
+"Gcs=syslin('c',Gc);\n",
+"figure;\n",
+"t=0:0.5:1000;\n",
+"u=0.1*ones(1,length(t));\n",
+"y=csim(u,t,Gcs)\n",
+"plot(t,y,2)\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Step disturbance response for PID compensation...\n",
+" of spacecraft','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('$theta$','fontsize',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.2_b: Frequency_response_characteristics_of_Lead_compensator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.2\n",
+"//Frequency response characteristics of Lead compensator.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its bode plot \n",
+"K=1, T=1, alpha=0.1\n",
+"s=poly(0,'s');\n",
+"sysD=syslin('c',K*(T*s+1)/(alpha*T*s+1));\n",
+"\n",
+"//The bode plot of the system\n",
+"\n",
+"fmin=0.1/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec)\n",
+"fmax=100/2/%pi; //maximum frq. in Hz for response (100 read/sec)\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax); \n",
+"//OR \n",
+"//Bode plot for frequency in rad/sec (scilab ver. 5.5.1)\n",
+"bode(sysD,fmin,fmax,'rad') \n",
+"\n",
+"//------------------------------------------------------------------\n",
+"title('(a) Magnitude and (b) phase for the lead compensator',...\n",
+"'fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.3: Bode_Plot_for_Real_Poles_and_Zeros.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.3\n",
+"//Bode Plot for Real Poles and Zeros.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its bode plot\n",
+"K=2000;\n",
+"s=poly(0,'s');\n",
+"Gs=syslin('c',(K*(s+0.5))/(s*(s+10)*(s+50)));\n",
+"\n",
+"//The bode plot of the system\n",
+"wmin=0.1; // mininmum frq. in rad/sec for response\n",
+"wmax=100; // maximum frq. in red/sec for response\n",
+"fmin=wmin/2/%pi // mininmum frq. in Hz for response\n",
+"fmax=wmax/2/%pi // maximum frq. in Hz for response\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax) \n",
+"//OR \n",
+"//(Only for scilab ver. 5.5.1)\n",
+"//Bode (frequency scale in rad/sec)\n",
+"// or gainplot or phaseplot plot with asymptotes\n",
+"figure(0)\n",
+"gainplot(Gs,fmin,fmax);\n",
+"bode_asymp(Gs,wmin,wmax);\n",
+"xstring(0.03,22,'slope=-1(-20db/dec)',0,0);\n",
+"xstring(0.2,9,'slope=0',0,0);\n",
+"xstring(3,7,'slope=-1(-20db/dec)',0,0)\n",
+"xstring(0.9,-8,'slope=-2(-40db/dec)',0,0)\n",
+"title('Composit plots (a) magnitude plot','fontsize',3);\n",
+"h=legend('');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//phase plot for poles and zeros\n",
+"zr=((s/0.5)+1)/s //infact this is zero and pole at origin. \n",
+"zr=syslin('c', zr);\n",
+"pl1=1/((s/10)+1) \n",
+"pl1=syslin('c', pl1);\n",
+"pl2=1/((s/50)+1) \n",
+"pl2=syslin('c', pl2);\n",
+"figure(1)\n",
+"phaseplot([Gs;zr;pl1;pl2],fmin,fmax);\n",
+"xstring(5.5,-14,'$\frac {1}{s/0.5+1}$',0,0);\n",
+"xstring(2.8,-22,'$\frac{1}{s/50+1}$',0,0);\n",
+"xstring(2.5,-60,'$\frac{1}{s/10+1}$',0,0); \n",
+"xstring(1.2,-100,['Composite';'(Actual)'],0,0);\n",
+"title('Composit plots (b) Phase','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"figure(2)\n",
+"bode(Gs,fmin,fmax,'rad'); //frequency scale n radians\n",
+"bode_asymp(Gs,wmin,wmax);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('(c) magnitude plot and phase plot approximate and actual...\n",
+"','fontsize',3)\n",
+"xstring(2.8,-22,'$\frac{1}{s/50+1}$',0,0);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.4: Bode_Plot_with_Complex_Poles.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.4\n",
+"//Bode Plot with Complex Poles.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its bode plot\n",
+"K=10;\n",
+"s=poly(0,'s');\n",
+"Gs=syslin('c',(K)/(s*(s^2+0.4*s+4)));\n",
+"//The bode plot of the system\n",
+"\n",
+"fmin=0.1/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec)\n",
+"fmax=10/2/%pi; //maximum frq. in Hz for response (100 read/sec)\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax); \n",
+"//OR \n",
+"//Bode plot for frequency in rad/sec (scilab ver. 5.5.1)\n",
+"bode(Gs,fmin,fmax,0.01,'rad') \n",
+"\n",
+"//------------------------------------------------------------------\n",
+"title(['Bode plot for a transfer function with complex poles';...\n",
+" '(a) magnitude...\n",
+" (b) phase'],'fontsize',3)\n",
+"\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.6: Bode_Plot_for_Complex_Poles_and_Zeros.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.6\n",
+"//Bode Plot for Complex Poles and Zeros:\n",
+"//Satellite with Flexible appendages.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its bode plot\n",
+"K=0.01;\n",
+"s=poly(0,'s');\n",
+"NumG=K*(s^2+0.01*s+1);\n",
+"DenG=s^2*((s^2/4)+0.02*(s/2)+1)\n",
+"sysG=syslin('c',NumG/DenG);\n",
+"\n",
+"fmin=0.09/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec)\n",
+"fmax=11/2/%pi; //maximum frq. in Hz for response (100 read/sec)\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax); \n",
+"//OR \n",
+"//Bode plot for frequency in rad/sec (scilab ver. 5.5.1)\n",
+"bode(sysG,fmin,fmax,0.01,'rad') \n",
+"\n",
+"//------------------------------------------------------------------\n",
+"title(['Bode plot for a transfer function with complex...\n",
+"poles and zeros'; '(a) magnitude (b) phase'],'fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"disp('NOTE : Result of the above example can be verified by checking the figures shown in example 6.5')"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.7: Computation_of_Kv.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.7\n",
+"//Computation of velocity error constant Kv from Bode plot\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its bode plot\n",
+"K=10;\n",
+"s=poly(0,'s');\n",
+"Gs=syslin('c',(K)/(s*(s+1)));\n",
+"//The bode plot of the system\n",
+"\n",
+"fmin=0.01/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec)\n",
+"fmax=10/2/%pi; //maximum frq. in Hz for response (100 read/sec)\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax); \n",
+"//OR \n",
+"//Bode plot for frequency in rad/sec (scilab ver. 5.5.1)\n",
+"bode(Gs,fmin,fmax,0.01,'rad')\n",
+"title(['Determination of Kv from the Bode plot for the system',...\n",
+"'$10/[s(s+1)]$'],'fontsize',3)\n",
+"//choose frequency (rad) and magnitude from bode plot and calculate Kv\n",
+"//Here at w=0.01, magngitude in db is M=60 \n",
+"//i.e actual magnitude of the reponse is |A|=10^(M/20)\n",
+"w=0.01; // in rad\n",
+"M=60 // in db\n",
+"A=10^(M/20) //actual gain\n",
+"\n",
+"//Velocity error constant Kv=w*|A(w)|\n",
+"Kv=w*A;\n",
+"disp(Kv,'The Velocity error Constant from bode plot is: ')\n",
+"//------------------------------------------------------------------\n",
+"// Computation of the Kv\n",
+"[frq repf]=repfreq(Gs,fmin,fmax);\n",
+"//frq in Hz, repf is freq. response in rectangular form. \n",
+"//From bode plot, Kv=w*|A(w)|\n",
+"//i.e Kv=2*pi*f*|A(2*pi*f)|\n",
+"\n",
+"idx=1;//selecting the frequency and response at that frequency from arrays\n",
+"Kv=2*%pi*frq(idx)*abs(repf(idx))\n",
+"disp(Kv,'The Velocity error Constant is computed at 0.0015915 Hz (0.01 rad/sec) : ')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.8: Nyquist_plot_for_a_second_order_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.8\n",
+"// Nyquist plot for a second order system.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus\n",
+"s=poly(0,'s');\n",
+"g=1/(s+1)^2;\n",
+"sysG=syslin('c',g);\n",
+"\n",
+"evans(sysG);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"title(['Root locus of','$G(s)=1/(s+1)^2$','with respect to K'],...\n",
+"'fontsize',3)\n",
+"zoom_rect([-3,-2,2,3])\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//------------------------------------------------------------------\n",
+"figure(1)\n",
+"//The bode plot of the system\n",
+"fmin=0.01/2/%pi; //mininmum frq. in Hz for response (0.1 rad/sec)\n",
+"fmax=100/2/%pi; //maximum frq. in Hz for response (100 read/sec)\n",
+"\n",
+"//Bode plot for frequency in Hz (scilab ver. 5.4.1)\n",
+"//bode(g,fmin,fmax); \n",
+"//OR \n",
+"//Bode plot for frequency in rad/sec (scilab ver. 5.5.1)\n",
+"bode(sysG,fmin,fmax,0.01,'rad') \n",
+"title(['Open loop bode plot for', '$G(s)=1/(s+1)^2$'],'fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"figure(2)\n",
+"//The nyquist plot of the system\n",
+"nyquist(sysG);\n",
+"title('Nyquist plot of the evaluation of K G(s) for s=C1 and K=1'...\n",
+",'fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6.9: Nyquist_plot_for_a_third_order_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 6.9\n",
+"// Nyquist plot for a third order system.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"g=syslin('c',1/(s*(s+1)^2));\n",
+"\n",
+"//The bode plot of the system\n",
+"fmin=0.01/2/%pi;\n",
+"fmax=100/2/%pi;\n",
+"//[frq,repf]=repfreq(g1,fmin,fmax,0.01);\n",
+"bode(g,fmin,fmax,'rad');\n",
+"frq=[1,10]/2/%pi;\n",
+"[frq, repf]=repfreq(g,frq);\n",
+"[db, phi]=dbphi(repf);\n",
+"plot(frq*2*%pi,db,'ro');\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Bode plot for','$G(s)=1/[s(s+1)^2]$'],'fontsize',3)\n",
+"//zoom_rect([[0.1 0] -70 [12 -180] 20])\n",
+"xset('font size', 3);\n",
+"\n",
+"xstring(1,0,'$C\,\, (\omega=1)$',0,0);\n",
+"xstring(2,-75,'$E\,\, (\omega=10)$',0,0);\n",
+"f=gca();\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//The nyquist plot of the system\n",
+"figure;\n",
+"nyquist(g,0.8/2/%pi,10/2/%pi,0.02)\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Nyquist plot for','$G(s)=1/[s(s+1)]^2$'],'fontsize',3)\n",
+"f=gca();\n",
+"f.x_location = 'origin';\n",
+"f.y_location = 'origin';\n",
+"zoom_rect([-1 -0.2 0.5 0.2]);\n",
+"xset('clipping', -1.2, 0.2, 1.4,0.4);\n",
+"xset('font size', 3);\n",
+"xset('color',2);\n",
+"xstring(-0.6,0.1,'${\fgcolor{blue}{\omega<0}}$',0,0);\n",
+"xstring(-0.6,-0.1,'${\fgcolor{blue}{\omega>0}}$',0,0);\n",
+"xstring(-0.7,0.005,'${\fgcolor{blue}{\omega=\pm 1}}$',0,0);\n",
+"xstring(-1,-0.2,...\n",
+"'${\fgcolor{blue}{\text{From \infty at \omega=0^+}}$',0,0);\n",
+" xstring(-0.7,0.15,'${\fgcolor{blue}...\n",
+" {\text{Towards \infty at \omega=0^-}}$',0,0);\n",
+"xstring(-0.525,-0.04,'C',0,0);\n",
+"xstring(-0.075,0,'E',0,0);\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/7-State_Space_Design.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/7-State_Space_Design.ipynb
new file mode 100644
index 0000000..4df674c
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/7-State_Space_Design.ipynb
@@ -0,0 +1,2207 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 7: State Space Design"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.10: Transformation_of_Thermal_System_from_Control_to_Modal_Form.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.10\n",
+"//Transformation of Thermal System from Control to Modal Form\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space matrices of the given system\n",
+"Ac=[-7 1; -12 0];\n",
+"Bc=[1;2];\n",
+"Cc=[1 0];\n",
+"Dc=0;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation in modal canonical form\n",
+"T=[4 -3;-1 1]\n",
+"Am=T\Ac*T;\n",
+"Bm=T\Bc;\n",
+"Cm=Cc*T;\n",
+"Dm=Dc;\n",
+"disp(Dm,'Dm',Cm,'Cm', Bm,'Bm',Am,'Am','Thermal System in modal canonical form')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.11: Poles_and_Zeros_of_Tape_Drive_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.11\n",
+"//Poles and Zeros of Tape Drive System.\n",
+"//Also, Transform the system into modal form\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space matrices of Tape Drive System\n",
+"F=[0 2 0 0 0;\n",
+"-0.1 -0.35 0.1 0.1 0.75;\n",
+"0 0 0 2 0;\n",
+"0.4 0.4 -0.4 -1.4 0;\n",
+"0 -0.03 0 0 -1];\n",
+"G=[0 0 0 0 1]';\n",
+"H2=[0 0 1 0 0];\n",
+"H3=[0.5 0 0.5 0 0];\n",
+"Ht=[-0.2 -0.2 0.2 0.2 0];\n",
+"//------------------------------------------------------------------\n",
+"// Poles (eigen values) of the system\n",
+"p=clean(spec(F));\n",
+"disp(p,'Poles of Tape Drive System are')\n",
+"//It requires complete state-space model.\n",
+"sys=syslin('c',F,G,[Ht;H2;H3],[0;0;0])\n",
+"// zeros of the system\n",
+"[tr]=trzeros(sys)\n",
+"disp(tr,'Transmission zeros of Tape Drive System are')\n",
+"//------------------------------------------------------------------\n",
+"// State space representation in modal canonical form with H3 output only.\n",
+"[m Am1]=spec(F)\n",
+"T1=[1/2 -%i/2;1/2 %i/2];\n",
+"//transformation for a complex pair of eigen values.\n",
+"temp=eye(5,5);\n",
+"T=[T1 zeros(2,3);zeros(3,2) eye(3,3)]; \n",
+"temp(1,1)=-1; temp(2,2)=-1; //for change in input output signs as desired\n",
+"M=m*T*temp //real Modal transformation\n",
+"Am=clean(M\F*M);\n",
+"Bm=clean(M\G);\n",
+"Cm=clean(H3*M);\n",
+"Dm=0;\n",
+"disp(Dm,'Dm',Cm,'Cm', Bm,'Bm',Am,'Am','Tape Drive System in modal canonical form')\n",
+"//------------------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.12: Transformation_of_Thermal_System_from_state_description.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.12\n",
+"//Transformation of Thermal System from state description\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space model of Thermal System\n",
+"s=%s;\n",
+"F=[-7 -12; 1 0];\n",
+"G=[1;0];\n",
+"H=[1 2];\n",
+"J=0;\n",
+"sys=syslin('c',F,G,H,J)\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function model of Thermal System\n",
+"[ch num den]=ss2tf(sys);\n",
+"disp(num/den, 'G=','Transfer function model of Thermal System')\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.13: Zeros_for_the_Thermal_System_from_a_State_Descriptio.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.13\n",
+"//Zeros for the Thermal System from a State Description\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space model of the given system\n",
+"F=[-7 -12; 1 0];\n",
+"G=[1;0];\n",
+"H=[1 2];\n",
+"J=0;\n",
+"sysG=syslin('c',F,G,H,J)\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function model\n",
+"[d num den]=ss2tf(sysG);\n",
+"zr=roots(num);\n",
+"disp(zr,'zr=');\n",
+"//Alternately, it can be obtained as\n",
+"zr=trzeros(sysG);\n",
+"disp(zr,'zr=');\n",
+"//------------------------------------------------------------------\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.14: Analysis_of_state_equations_of_Tape_Drive.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.14\n",
+"//Analysis of state equations of Tape Drive.\n",
+"//compute the poles, zeros and transfer function of Tape Drive System.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space matrices of Tape Drive System\n",
+"F=[0 2 0 0 0;\n",
+"-0.1 -0.35 0.1 0.1 0.75;\n",
+"0 0 0 2 0;\n",
+"0.4 0.4 -0.4 -1.4 0;\n",
+"0 -0.03 0 0 -1];\n",
+"G=[0 0 0 0 1]';\n",
+"H2=[0 0 1 0 0];\n",
+"H3=[0.5 0 0.5 0 0];\n",
+"Ht=[-0.2 -0.2 0.2 0.2 0];\n",
+"//------------------------------------------------------------------\n",
+"//Poles (eigen values) of the system\n",
+"p=clean(spec(F));\n",
+"disp(p,'P','Poles of Tape Drive System are (for any output)')\n",
+"disp('************************************************************')\n",
+"disp('pole and zero polynomials and transfer function...\n",
+" for a system with output H2')\n",
+"sys2=syslin('c',F,G,H2,0);\n",
+"[d2 num2 den2]=ss2tf(sys2);\n",
+"N2=coeff(num2);\n",
+"D2=coeff(den2);\n",
+"disp(D2,'D2',N2,'N2')\n",
+"// zeros of the system with output H2\n",
+"[zer2]=trzeros(sys2)\n",
+"disp(zer2,'ZER2','zeros are')\n",
+"// transfer function of the system with output H2\n",
+"G2=clean(num2/den2);\n",
+"disp(G2,'G2(s)=N2(s)/D2(s)=')\n",
+"disp('************************************************************')\n",
+"disp('pole and zero polynomials and transfer function for a...\n",
+" system with output H3')\n",
+"sys3=syslin('c',F,G,H3,0);\n",
+"[d3 num3 den3]=ss2tf(sys3);\n",
+"N3=coeff(num3);\n",
+"D3=coeff(den3);\n",
+"disp(D3,'D3',N3,'N3')\n",
+"// zeros of the system with output H3\n",
+"[zer3]=trzeros(sys3)\n",
+"disp(zer3,'ZER3','zeros are')\n",
+"// transfer function of the system with output H3\n",
+"G3=clean(num2/den2);\n",
+"disp(G3,'G3(s)=N3(s)/D3(s)=')\n",
+"disp('************************************************************')\n",
+"disp('pole and zero polynomials and transfer function for a...\n",
+" system with output Ht')\n",
+"syst=syslin('c',F,G,Ht,0);\n",
+"[dt numt dent]=ss2tf(syst);\n",
+"Nt=coeff(numt);\n",
+"Dt=coeff(dent);\n",
+"disp(Dt,'Dt',Nt,'Nt','zeros are')\n",
+"// zeros of the system with output Ht\n",
+"[zert]=trzeros(syst)\n",
+"disp(zert,'ZERT')\n",
+"// transfer function of the system with output Ht\n",
+"Gt=clean(numt/dent);\n",
+"disp(Gt,'G(s)=Nt(s)/Dt(s)=')\n",
+"disp('************************************************************')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.15: Control_law_for_a_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.15\n",
+"//Control law for a pendulum.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Pendulum state model;\n",
+"w0=1;\n",
+"F=[0 1;-w0^2 0];\n",
+"G=[0 1]';\n",
+"H=eye(2,2); //representing x1 and x2 states as outputs\n",
+"J=[0 0]';\n",
+"sys=syslin('c',F,G,H,J); //open loop system\n",
+"x0=[1 0]' //initial condition \n",
+"t=0:0.2:7;\n",
+"y=csim('impulse',t,sys); //open loop response\n",
+"//------------------------------------------------------------------\n",
+"//simulation for closed loop system\n",
+"x0=[1 0]' //initial condition \n",
+"//control law u=-Kx;\n",
+"K=[3*w0^2 4*w0];\n",
+"syscl=syslin('c',(F-G*K),G,H,J); //closed loop system\n",
+"t=0:0.1:7;\n",
+"u=zeros(1,length(t));\n",
+"[x z]=csim(u,t,syscl,x0); //closed loop response\n",
+"plot(t',x');\n",
+"u=-K*x;\n",
+"plot(t',u'/4,'r--'); //control law u plot (scaled to 1/4 in figure);\n",
+"legend('x1','x2','u/4')\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Impulse response of undamped oscillator with full-state...\n",
+" feedback(w0=1)','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.16: Ackermanns_formula_for_undamped_oscillator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.16\n",
+"//Ackermann's formula for undamped oscillator.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//undamped oscillator (Pendulum) state model;\n",
+"w0=1;\n",
+"F=[0 1;-w0^2 0];\n",
+"G=[0 1]';\n",
+"H=eye(2,2); //representing x1 and x2 states as outputs\n",
+"J=[0 0]';\n",
+"//------------------------------------------------------------------\n",
+"//Ackermann's formula for feedback gain computation\n",
+"pc=[-2 -2]; //desired poles\n",
+"exec('./acker_dk.sci', -1);\n",
+"[K,eig]=acker_dk(F,G,pc)\n",
+"disp(K,'Feedback gain K=')\n",
+"disp(eig,'Closed loop eigen values are ')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.17: How_zero_location_affect_control_law.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.17 How zero location affect control law\n",
+"// Obtain state feedback gain matrix for the given system\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//(a) state feedback gain matrix for zero at 2.\n",
+"//Location of system Zero\n",
+"z0=2;\n",
+"\n",
+"// State space representation\n",
+"Ao=[-7 1;-12 0];\n",
+"Bo=[1 -z0]';\n",
+"Co=[1 0];\n",
+"Do=0;\n",
+"\n",
+"// Desired poles\n",
+"Pd=[1 2 4];\n",
+"Pc=roots(Pd);\n",
+"\n",
+"\n",
+"// State feedback gain matrix for system zero at -2.0\n",
+"K=ppol(Ao,Bo,Pc)\n",
+"disp(K,'K=','State feeback gain for a system with zero at 2' )\n",
+"//------------------------------------------------------------------\n",
+"//Location of system Zero\n",
+"z0=-2.99\n",
+"B=[1 -z0]';\n",
+"// State feedback gain matrix for system zero...\n",
+"// at -2.99 (by ackermann's formula)\n",
+"exec('./acker_dk.sci', -1);\n",
+"K1=acker_dk(Ao,B,Pc)\n",
+"disp(K1,'K1','State feeback gain for a system with zero at -2.99')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.18: Introducing_the_reference_input.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.18\n",
+"//Introducing the reference input.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Pendulum state model;\n",
+"w0=1;\n",
+"F=[0 1;-w0^2 0];\n",
+"G=[0 1]';\n",
+"H=[1 0]; //representing x1 and x2 states as outputs\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//computing state feedback matrix to place poles at [-2 -2]\n",
+"exec('./acker_dk.sci', -1);\n",
+"K=acker_dk(F,G,[-2, -2]);\n",
+"//------------------------------------------------------------------\n",
+"//augmented matrix for tracking the reference\n",
+"A=[F G;H J];\n",
+"N=A\[zeros(1,n) 1]';\n",
+"Nx=N(1:n);\n",
+"Nu=N(n+1);\n",
+"//feedforward gain (input weight)\n",
+"Ntilde=Nu+K*Nx;\n",
+"//------------------------------------\n",
+"//Alternately, it can be computed as /\n",
+"Ntilde1=-inv(H*inv(F-G*K)*G); // /\n",
+"//------------------------------------\n",
+"//Closed loop system and step response\n",
+"syscl=syslin('c',(F-G*K),G*Ntilde,H,J); //closed loop system\n",
+"t=0:0.1:7;\n",
+"[y x]=csim('step',t,syscl); //closed loop response\n",
+"plot(t',x');\n",
+"u=-K*x+Ntilde;\n",
+"plot(t',u'/4,'r--'); //control law u plot (scaled to 1/4 in figure);\n",
+"legend('x1','x2','u/4');\n",
+"xset('font size',3);\n",
+"xstring(5,0.93,'$x_{ss}$')\n",
+"xstring(5,0.25,'$u_{ss}$')\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Step response of undamped oscillator to reference input',...\n",
+"'fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel('Amplitude','fontsize',2);\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.19: Reference_input_to_Type1_control_system_DC_Motor.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.19\n",
+"//Reference input to Type-1 control system: DC Motor\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//Location of system Zero\n",
+"z0=2;\n",
+"\n",
+"// State space representation\n",
+"F=[0 1;0 -1];\n",
+"G=[0 1]';\n",
+"H=[1 0]; \n",
+"J=0;\n",
+"n=sqrt(length(F)); //order of the system\n",
+"\n",
+"//computing state feedback matrix to place poles at assumed location [-1 -2]\n",
+"exec('./acker_dk.sci', -1);\n",
+"K=acker_dk(F,G,[-1, -2]); //assume pd=[-1 -2]\n",
+"//------------------------------------------------------------------\n",
+"//augmented matrix for tracking the reference\n",
+"A=[F G;H J];\n",
+"N=A\[zeros(1,n) 1]';\n",
+"Nx=N(1:n);\n",
+"Nu=N(n+1);\n",
+"disp(Nx,'Nx',Nu,'Nu')\n",
+"\n",
+"//feedforward gain (input weight)\n",
+"Ntilde=Nu+K*Nx;\n",
+"disp(Ntilde,'N_tilde','Input gain: N_tilde =Nu+K Nx')\n",
+"//------------------------------------------------------------------\n",
+"// Verify if ||y-r|| -> 0;\n",
+"\n",
+"syscl=syslin('c',(F-G*K),G*Ntilde,H,J); //closed loop system\n",
+"\n",
+"t=0:0.1:10;\n",
+"r=ones(1,length(t));//reference input\n",
+"[y x]=csim('step',t,syscl); //closed loop response\n",
+"\n",
+"e=sqrt((r-y).^2) //norm of error\n",
+"plot(t,y);\n",
+"plot(t,r,'m:'); //reference input\n",
+"plot(t,e,'r-.'); //norm of error\n",
+"xset('font size',3);\n",
+"xstring(3,0.83,'y')\n",
+"xstring(2,1,'r')\n",
+"xstring(3,0.1,'$\|e\|$')\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Step response of undamped oscillator to reference input','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel('Amplitude','fontsize',2);\n",
+"zoom_rect([0 -0.1 10 1.1])\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.20: Pole_Placement_as_a_Dominant_Second_Order_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.20\n",
+"// Pole Placement as a Dominant Second-Order System\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"clc;\n",
+"clear all;\n",
+"\n",
+"// State space representation\n",
+"F=[0 2 0 0 0;-0.10 -0.35 0.1 0.1 0.75; 0 0 0 2 0;...\n",
+" 0.4 0.4 -0.4 -1.4 0; 0 -0.03 0 0 -1];\n",
+"G=[0 0 0 0 1]';\n",
+"H=[0.5 0 0.5 0 0]; //Tape position at the head\n",
+"Ht=[-0.2 -0.2 0.2 0.2 0]; //Tension output\n",
+"J=0;\n",
+"n=sqrt(length(F))\n",
+"// Desired poles\n",
+"Pc=[-0.707+0.707*%i -0.707-0.707*%i -4 -4 -4]/1.5;\n",
+"//------------------------------------------------------------------\n",
+"// State feedback gain matrix via LQR (riccati equation)\n",
+"Q = eye(5,5);\n",
+"R =1\n",
+"// Riccati equation\n",
+"P=riccati(F, G*inv(R)*G', Q, 'c')\n",
+"K1=inv(R)*G'*P\n",
+"//------------------------------------------------------------------\n",
+"// State feedback gain matrix via pole-placement\n",
+"exec('./acker_dk.sci', -1);\n",
+"K2=acker_dk(F,G,Pc);\n",
+"disp(K2,'K2=','Gain by ackermans formula' );\n",
+"//------------------------------------------------------------------\n",
+"Ntilde1=-inv(H*inv(F-G*K1)*G); //input gain for LQR feedback gain.\n",
+"Ntilde2=-inv(H*inv(F-G*K2)*G); //input gain for Ackerman's feedback gain.\n",
+"\n",
+"syscl1=syslin('c',(F-G*K1),G*Ntilde1,H,J); //closed loop system with K1\n",
+"syscl2=syslin('c',(F-G*K2),G*Ntilde2,H,J); //closed loop system with K2\n",
+"\n",
+"t=0:0.1:12;\n",
+"[y1 x1]=csim('step',t,syscl1); //response of position head with K1\n",
+"[y2 x2]=csim('step',t,syscl2); //response of position head with K2\n",
+"\n",
+"//plot of a position of read write head\n",
+"plot(t,y1,'m-.'); //Design via LQR\n",
+"plot(t,y2,2); //Design via Ackerman's Formula\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Step response of tape servomotor designs','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel('Tape Posotion','fontsize',2);\n",
+"\n",
+"xstring(2.5,1.1,'LQR')\n",
+"xarrows([3;4],[1.1;0.95],-1,1)\n",
+"xstring(5,0.7,['Dominant';'second order'])\n",
+"xarrows([5;4.2],[0.8;0.9],-1.5,1)\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//response as a tape tension\n",
+"yt1=Ht*x1;\n",
+"yt2=Ht*x2;\n",
+"\n",
+"figure(1)\n",
+"plot(t,yt1,'m-.'); //Design via LQR\n",
+"plot(t,yt2,2); //Design via Ackerman's Formula\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Tension plots for tape servomotor step responses','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel('Tape Tension','fontsize',2);\n",
+"\n",
+"xstring(3.5,0,'LQR')\n",
+"xarrows([3.7;4.7],[0;0],-1)\n",
+"xstring(6.1,-0.015,['Dominant';'second order'])\n",
+"xarrows([6;6],[-0.013;-0.002],-1)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.21: Symmetric_root_locus_for_servo_speed_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.21\n",
+"// Symmetric root locus (SRL) for servo speed control\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function model of the given system\n",
+"a=1.5;//assume\n",
+"s=poly(0,'s');\n",
+"nums=1;\n",
+"dens=s+a;\n",
+"num_s=1;\n",
+"den_s=-s+a;\n",
+"G0s=syslin('c',nums/dens); //G0(s)\n",
+"G0_s=syslin('c',num_s/den_s); //G0(-s)\n",
+"\n",
+"evans(G0s)\n",
+"evans(G0_s)\n",
+"zoom_rect([-3 -0.1 3 0.1])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Symmetric root locus for a first order system','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Root locus design\n",
+"//rho>0; choose rho=2\n",
+"rho=2;\n",
+"//optimal pole p=-sqrt(a^2+rho)\n",
+"p=-sqrt(a^2+rho)\n",
+"sig=real(p);\n",
+"omega=imag(p);\n",
+"plot(sig,omega,'ro')\n",
+"xstring(-2.5,0.02,['pole location at';'$\rho=2$'])\n",
+"xarrows([-2.2;-2.07],[0.02;0.002],-1.5,1)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.22: SRL_design_for_satellite_attitude_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.22\n",
+"// SRL design for satellite attitude control\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function for satellite attitude control system\n",
+"s=poly(0,'s');\n",
+"nums=1;\n",
+"dens=s^2;\n",
+"num_s=1;\n",
+"den_s=(-s)^2;\n",
+"G0s=syslin('c',nums/dens); //G0(s)\n",
+"G0_s=syslin('c',num_s/den_s); //G0(-s)\n",
+"//evans(G0s*G0_s)\n",
+"evans(1/s^4)\n",
+"zoom_rect([-3 -3 3 3])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Symmetric root locus for the satellite','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Root locus design\n",
+"//choose rho=4.07 that places pole at -1+-j\n",
+"rho=4.07;\n",
+"chr_eqn=(1+rho*G0s*G0_s)\n",
+"p=[-1+%i, -1-%i];\n",
+"sig=real(p);\n",
+"omega=imag(p);\n",
+"plot(sig,omega,'ro')\n",
+"xstring(-2.2,0.5,['pole locations at';'$\rho=4.07$'])\n",
+"//------------------------------------------------------------------\n",
+"//pole-placement design;\n",
+"sys=tf2ss(G0s);\n",
+"exec('./acker_dk.sci', -1);\n",
+"K=acker_dk(sys.A,sys.B,p);\n",
+"syscl=syslin('c',(sys.A-sys.B*K),sys.B, sys.C, sys.D)\n",
+"disp(spec(syscl.A),'Closed loop eigen values');\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.23: SRL_design_for_an_inverted_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.23\n",
+"// SRL Design for an Inverted Pendulum \n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//Transfer function model of Inverted Pendulum.\n",
+"s=poly(0,'s');\n",
+"\n",
+"nums=-(s+2);\n",
+"dens=(s^2-1)\n",
+"num_s=-(-s+2);\n",
+"den_s=((-s)^2-1)\n",
+"G0s=syslin('c',nums/dens); //G0(s)\n",
+"G0_s=syslin('c',num_s/den_s); //G0(-s)\n",
+"sysGG=G0s*G0_s;\n",
+"evans(sysGG)\n",
+"title('Symmetric root locus for Inverted Pendulum')\n",
+"zoom_rect([-3 -2 3 2])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Symmetric root locus for the inverted pendulum','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Root locus design\n",
+"//choose rho=1 that places pole at -1.36+-j0.606\n",
+"rho=1;\n",
+"p=[-1.36+0.606*%i, -1.36-0.606*%i];\n",
+"sig=real(p);\n",
+"omega=imag(p);\n",
+"plot(sig,omega,'ro')\n",
+"xstring(-1.25,0.5,['pole locations at';'$\rho=1$'])\n",
+"//------------------------------------------------------------------\n",
+"//pole-placement design;\n",
+"Ac=[0 1;1 0];Bc=[0 -1]'; Cc=[2 1];Dc=0;\n",
+"exec('./acker_dk.sci', -1);\n",
+"K=acker_dk(Ac,Bc,p);\n",
+"disp(K,'K=',spec(Ac-Bc*K),'Closed loop eigen values');\n",
+"\n",
+"//input gain calculation\n",
+"n=sqrt(length(Ac));\n",
+"A=[Ac Bc;Cc Dc];\n",
+"N=A\[zeros(1,n) 1]';\n",
+"Nx=N(1:n);\n",
+"Nu=N(n+1);\n",
+"\n",
+"//feedforward gain (input gain)\n",
+"Ntilde=Nu+K*Nx;\n",
+"\n",
+"//Step respose\n",
+"t=0:0.1:4.5;\n",
+"syscl=syslin('c',(Ac-Bc*K),Bc*Ntilde, Cc, Dc)\n",
+"[y x]=csim('step',t,syscl); //closed loop response\n",
+"figure,\n",
+"plot(t,y);\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Step response for inverted pendulum','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel(['Position','$x_1$'],'fontsize',2);\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.24: LQR_Design_for_a_Tape_Drive.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.24\n",
+"// LQR Design for a Tape Drive\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space model for a Tape Drive\n",
+"F=[0 2 0 0 0;-0.10 -0.35 0.1 0.1 0.75; 0 0 0 2 0; 0.4 0.4 -0.4 -1.4 0; 0 -0.03 0 0 -1];\n",
+"G=[0 0 0 0 1]';\n",
+"H3=[0.5 0 0.5 0 0];\n",
+"//------------------------------------------------------------------\n",
+"// State feedback gain matrix via LQR (riccati equation)\n",
+"// (a) Continuous LQR for rho=1\n",
+"rho=1;\n",
+"R1=1;\n",
+"Q1=rho*H3'*H3;\n",
+"// Riccati equation\n",
+"P1=riccati(F, G*inv(R1)*G', Q1, 'c')\n",
+"K1=inv(R1)*G'*P1\n",
+"disp(K1,'K1')\n",
+"//------------------------------------------------------------------\n",
+"// State feedback gain matrix via LQR (riccati equation)\n",
+"// (a) Comparision in step response with rho=0.1,1,10.\n",
+"rho=0.1;\n",
+"R2=1;\n",
+"Q2=rho*H3'*H3;\n",
+"// Riccati equation\n",
+"P2=riccati(F, G*inv(R2)*G', Q2, 'c')\n",
+"K2=inv(R2)*G'*P2\n",
+"\n",
+"rho=10;\n",
+"R3=1;\n",
+"Q3=rho*H3'*H3;\n",
+"// Riccati equation\n",
+"P3=riccati(F, G*inv(R3)*G', Q3, 'c')\n",
+"K3=inv(R3)*G'*P3\n",
+"//------------------------------------------------------------------\n",
+"//input gains for step reference with rho=0.1,1,10.\n",
+"Ntilde1=-inv(H3*inv(F-G*K1)*G);\n",
+"Ntilde2=-inv(H3*inv(F-G*K2)*G);\n",
+"Ntilde3=-inv(H3*inv(F-G*K3)*G);\n",
+"\n",
+"//Closed loop system with rho=0.1,1,10.\n",
+"syscl1=syslin('c',(F-G*K1),G*Ntilde1,H3,0);\n",
+"syscl2=syslin('c',(F-G*K2),G*Ntilde2,H3,0);\n",
+"syscl3=syslin('c',(F-G*K3),G*Ntilde3,H3,0);\n",
+"\n",
+"//step response with rho=0.1,1,10.\n",
+"t=0:0.1:12;\n",
+"[y1 x1]=csim('step',t,syscl1); //closed loop response\n",
+"[y2 x2]=csim('step',t,syscl2); //closed loop response\n",
+"[y3 x3]=csim('step',t,syscl3); //closed loop response\n",
+"\n",
+"figure,\n",
+"a1=newaxes();\n",
+"a1.axes_bounds=[0,0,1.0,0.5];\n",
+"plot(t,y1);\n",
+"plot(t,y2,'r-.');\n",
+"plot(t,y3,'m:');\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('(a)Step response of step servo motor for LQR Design','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel(['Tape Position','$x_3$'],'fontsize',2);\n",
+"\n",
+"xstring(4.1,0.85,'$\rho=1$')\n",
+"xstring(5.5,0.75,'$\rho=0.1$')\n",
+"xstring(2.1,1.05,'$\rho=10$')\n",
+"//------------------------------------------------------------------\n",
+"//Tensions for the Tape\n",
+"//For tape output is Ht=[-0.2 -0.2 0.2 0.2 0];\n",
+"Ht=[-0.2 -0.2 0.2 0.2 0];\n",
+"H3=Ht;\n",
+"//input gains can not be computed because of singularity. so set it 1;\n",
+"Ntilde1=1;\n",
+"Ntilde2=1;\n",
+"Ntilde3=1;\n",
+"\n",
+"//Closed loop system with rho=0.1,1,10.\n",
+"syscl1=syslin('c',(F-G*K1),G*Ntilde1,H3,0);\n",
+"syscl2=syslin('c',(F-G*K2),G*Ntilde2,H3,0);\n",
+"syscl3=syslin('c',(F-G*K3),G*Ntilde3,H3,0);\n",
+"\n",
+"//step response with rho=0.1,1,10.\n",
+"t=0:0.1:12;\n",
+"[y1 x1]=csim('step',t,syscl1); //closed loop response\n",
+"[y2 x2]=csim('step',t,syscl2); //closed loop response\n",
+"[y3 x3]=csim('step',t,syscl3); //closed loop response\n",
+"\n",
+"a2=newaxes();\n",
+"a2.axes_bounds=[0,0.5,1.0,0.5];\n",
+"plot(t,y1);\n",
+"plot(t,y2,'r-.');\n",
+"plot(t,y3,'m:');\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('(b)Corresponding tension for Tape servomotor step response','fontsize',3);\n",
+"xlabel('Time t (sec.)','fontsize',2);\n",
+"ylabel(['Tape Tension','T'],'fontsize',2);\n",
+"\n",
+"\n",
+"xstring(4.3,-0.05,'$\rho=1$')\n",
+"xstring(6,-0.1,'$\rho=0.1$')\n",
+"xstring(1.5,-0.03,'$\rho=10$')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.25: An_estimator_design_for_a_simple_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.25\n",
+"// An estimator design for a simple pendulum\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation\n",
+"w0=1;\n",
+"F=[0 1; -w0^2 0];\n",
+"G=[0 1]';\n",
+"H=[1 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));//order of the system\n",
+"// Desired estimator poles\n",
+"Pe=[-10*w0 -10*w0];\n",
+"// Observer gain matrix for system \n",
+"Lt=ppol(F',H',Pe);\n",
+"L=Lt';\n",
+"disp(L,'L=' );\n",
+"//------------------------------------------------------------------\n",
+"//simulation for closed loop system\n",
+"x0=[1 0]' //initial condition\n",
+"\n",
+"//State feedback control law u=-Kx; (from Ex7_15)\n",
+"K=[3*w0^2 4*w0];\n",
+"//------------------------------------------------------------------\n",
+"//Augmented plant and observer\n",
+"Faug=[F-G*K, zeros(n,n); L*H, F-L*H];\n",
+"Gaug=[0 0 0 0]';\n",
+"Haug=[H -H];\n",
+"Jaug=0;\n",
+"\n",
+"sys_aug=syslin('c',Faug,Gaug,Haug,Jaug);\n",
+"t=0:0.1:4;\n",
+"u=zeros(1,length(t));\n",
+"x0=[1 0 0 0]';\n",
+"[x z]=csim(u,t,sys_aug,x0); //closed loop response\n",
+"plot(t,z(1,:));\n",
+"plot(t,z(2,:),'m');\n",
+"plot(t,z(3,:),'b:');\n",
+"plot(t,z(4,:),'m:');\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title(['Initial condition response of oscillator showing',...\n",
+"'$\mathbf{x}$','and','$\hat{\mathbf{x}}$'],'fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"legend('$x_1$','$x_2$','$\hat{x}_1$','$\hat{x}_2$')\n",
+"xset('font size',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.26: A_reduced_order_estimator_design_for_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.26\n",
+"// A reduced order estimator design for pendulum\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation\n",
+"w0=1;\n",
+"F=[0 1; -w0^2 0];\n",
+"G=[0 1]';\n",
+"H=[1 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));//order of the system\n",
+"\n",
+"//partioned system\n",
+"Faa=F(1,1); Fab=F(1,2);\n",
+"Fba=F(2,1); Fbb=F(2,2);\n",
+"\n",
+"// Desired estimator poles\n",
+"Pe=[-10];\n",
+"// Observer gain matrix for system \n",
+"L=ppol(Fbb',Fab',Pe);\n",
+"L=L';\n",
+"disp(L,'L=' );\n",
+"//------------------------------------------------------------------\n",
+"//simulation for closed loop system\n",
+"x0=[1 0 10]' //initial condition\n",
+"\n",
+"//State feedback control law u=-Kx; (from Ex7_15)\n",
+"K=[3*w0^2 4*w0];\n",
+"//------------------------------------------------------------------\n",
+"//Augmented plant and observer\n",
+"Faug=[F-G*K, zeros(n,1); Fab, L*Fab, Fbb-L*Fab];\n",
+"Gaug=[0 0 0]';\n",
+"Haug=[H 0];\n",
+"J=0;\n",
+"\n",
+"sys_aug=syslin('c',Faug,Gaug,Haug,J);\n",
+"t=0:0.1:4;\n",
+"u=zeros(1,length(t));\n",
+"[x z]=csim(u,t,sys_aug,x0); //closed loop response\n",
+"plot(t,z(1,:),'b');\n",
+"plot(t,z(2,:),'r');\n",
+"plot(t,z(3,:),'r--');\n",
+"\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Initial condition response of the reduced order estimator','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"legend('$x_1$','$x_2$','$\hat{x}_2$')\n",
+"xset('font size',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.27: SRL_estimator_design_for_a_simple_pendulum.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.27\n",
+"// SRL estimator design for a simple pendulum\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation\n",
+"F=[0 1; -1 0];\n",
+"G=[0 1]';\n",
+"H=[1 0];\n",
+"J=0;\n",
+"\n",
+"//Transfer function\n",
+"sys=syslin('c',F,G,H,J)\n",
+"sysGG=ss2tf(sys)\n",
+"\n",
+"//Symmetric root locus for the inverted pendulum estimator design\n",
+"//------------------------------------------------------------------\n",
+"//Root locus design\n",
+"evans(sysGG*sysGG)\n",
+"zoom_rect([-5 -5 5 5])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Symmetric root locus for inverted the pendulum estimator design',...\n",
+"'fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//pole locations for q=365; p=-3+-j3.18\n",
+"p=[-3+3.18*%i -3-3.18*%i]\n",
+"sig=real(p);\n",
+"omega=imag(p);\n",
+"plot(sig,omega,'ro')\n",
+"xstring(-4,1,['pole location at';'q=365'])\n",
+"xarrows([-3.5;-3.05],[2;3.1],-1.5,1)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.28: Full_order_compensator_design_for_satellite_attitude_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.28\n",
+"// Full order compensator design for satellite attitude control.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"A=[0 1; 0 0];\n",
+"B=[0 1]';\n",
+"C=[1 0];\n",
+"D=0;\n",
+"n=sqrt(length(A));\n",
+"//Desired poles for the satellite attitude control system.\n",
+"Pc=[-0.707+0.707*%i -0.707-0.707*%i ]\n",
+"\n",
+"// State feedback gain\n",
+"K=ppol(A,B,Pc)\n",
+"disp(K,'K=','State feedback gain')\n",
+"\n",
+"//Estimator - error roots are at\n",
+"Pe=[-2.5+4.3*%i -2.5-4.3*%i]\n",
+"L=ppol(A',C',Pe);\n",
+"L=L';\n",
+"disp(L,'L=','Observer gain')\n",
+"//------------------------------------------------------------------\n",
+"//Compensator Design\n",
+"sys1=syslin('c',A,B,C,D);\n",
+"G=ss2tf(sys1);\n",
+"s=poly(0,'s');\n",
+"\n",
+"Ds=-K*inv(s*eye(n,n)-A+B*K+L*C)*L;\n",
+"\n",
+"exec('./zpk_dk.sci', -1);\n",
+"[pl,zr Kp]=zpk_dk(Ds);\n",
+"D=poly(zr,'s','roots')/poly(pl,'s','roots')\n",
+"\n",
+"evans(G*D)\n",
+"zoom_rect([-8 -6 8 6])\n",
+"\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Root locus for combined control and estimator,...\n",
+" with process gain as the parameter','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Frequnecy response for 1/s^2 and compensated\n",
+"\n",
+"figure,\n",
+"bode([-Ds*G;G],0.01/2/%pi,100/2/%pi,'rad');\n",
+"title(['Frequency response for','$G(s)=1/s^2$'],'fontsize',3)\n",
+"legend('Compensated','Uncompensated')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.29: A_reduced_order_compensator_design_for_a_satellite_attitude_control.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.29\n",
+"// A reduced order compensator design for a satellite attitude control\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation\n",
+"F=[0 1;0 0];\n",
+"G=[0 1]';\n",
+"H=[1 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));//order of the system\n",
+"\n",
+"//partioned system\n",
+"Faa=F(1,1); Fab=F(1,2);\n",
+"Fba=F(2,1); Fbb=F(2,2);\n",
+"Ga=G(1);Gb=G(2);\n",
+"\n",
+"// Desired estimator poles\n",
+"Pe=[-5];\n",
+"// Observer gain matrix for system \n",
+"L=ppol(Fbb',Fab',Pe);\n",
+"L=L';\n",
+"disp(L,'L=' );\n",
+"//------------------------------------------------------------------\n",
+"//State feedback control law u=-Kx=-(K+[L*k2 0])[y xc]'; \n",
+"k1=1; k2=sqrt(2);\n",
+"K=[k1 k2];\n",
+"Kc=K+[L*k2 0];\n",
+"//------------------------------------------------------------------\n",
+"//compensator differential equation\n",
+"//xc_dot=(Fbb-L*Fab)*xb_hat + (Fba - L*Faa)*y + (Gb - L*Ga)*u\n",
+"//xc_dot=((Fbb-L*Fab)-k2)*xc + [(Fba - L*Faa)-(Gb - L*Ga)*(k1+L*k2)+L*(Fbb-L*Fab)]*y \n",
+"Fc=(Fbb-L*Fab)-Gb*k2\n",
+"Fy=(Fba - L*Faa)-(Gb - L*Ga)*(k1+k2*L)+(Fbb-L*Fab)*L\n",
+"//compensator transfer function\n",
+"s=poly(0,'s');\n",
+"Gest=syslin('c',Fy/(s-Fc))//estimator transfer function\n",
+"Dcr=-[k1+L*k2+k2*Gest]\n",
+"disp(Dcr,'Dcr','compensator transfer function')\n",
+"//------------------------------------------------------------------\n",
+"//Root locus with reduced order compensator\n",
+"G=1/s^2;\n",
+"G=syslin('c',G);\n",
+"exec('./zpk_dk.sci', -1);\n",
+"[pl,zr Kp]=zpk_dk(Dcr);\n",
+"\n",
+"Dcr=poly(zr,'s','roots')/poly(pl,'s','roots')\n",
+"Dcr=syslin('c',Dcr);\n",
+"evans(G*Dcr)\n",
+"zoom_rect([-8 -4 2 4])\n",
+"\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title(['Root locus of a reduced order controller and','$1/s^2$',...\n",
+" 'process'],'fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Frequnecy response for 1/s^2 and compensated\n",
+"\n",
+"figure,\n",
+"bode([-Kp*G*Dcr;G],0.01/2/%pi,100/2/%pi,'rad');\n",
+"title(['Frequency response','$G(s)=1/s^2$', 'with a reduced...\n",
+" order estimator'],'fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('Compensated','Uncompensated')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.2_b: Cruise_control_system_step_response.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.2\n",
+"//Cruise control system step response.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Cruise control system parameters\n",
+"m=1000;\n",
+"b=50;\n",
+"u=500;\n",
+"\n",
+"// Transfer function\n",
+"s=%s; // or \n",
+"s=poly(0,'s');\n",
+"sys1=syslin('c',(1/m)/(s+b/m));\n",
+"disp(sys1)\n",
+"//------------------------------------------------------------------\n",
+"F=[0 1; 0 -b/m];\n",
+"G=[0;1/m];\n",
+"H=[0 1];\n",
+"J=0;\n",
+"sys=syslin('c',F,G,H,J);\n",
+"//------------------------------------------------------------------\n",
+"//step response to u=500;\n",
+"t=0:0.5:100;\n",
+"v=csim('step',t,u*sys);\n",
+"plot(t,v,2)\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Responses of car velocity to a step in u','fontsize',3)\n",
+"xlabel('Time t (sec.)','fontsize',2)\n",
+"ylabel('Amplitude','fontsize',2)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.30: Full_Order_Compensator_Design_for_DC_Servo.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.30\n",
+"// Full-Order Compensator Design for DC Servo.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"//Transfer function model for DC Servo\n",
+"s=poly(0,'s');\n",
+"num=10;\n",
+"den=s*(s+2)*(s+8);\n",
+"Gs=syslin('c',num/den);\n",
+"\n",
+"// State space representation\n",
+"F=[-10 1 0;-16 0 1;0 0 0];\n",
+"G=[0 0 10]';\n",
+"H=[1 0 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//Desired poles for the DC Servo system.\n",
+"Pc=[-1.42 -1.04+2.14*%i -1.04-2.14*%i ]\n",
+"\n",
+"\n",
+"// State feedback gain\n",
+"K=ppol(F,G,Pc)\n",
+"disp(K,'K=','State feedback gain')\n",
+"\n",
+"//Estimator - error roots are at\n",
+"Pe=[-4.25 -3.13+6.41*%i -3.13-6.41*%i]\n",
+"L=ppol(F',H',Pe);\n",
+"L=L';\n",
+"disp(L,'L=','Observer gain')\n",
+"//------------------------------------------------------------------\n",
+"//Compensator Design\n",
+"DK=-K*inv(s*eye(n,n)-F+G*K+L*H)*L;\n",
+"\n",
+"exec('./zpk_dk.sci', -1);\n",
+"[p,z]=zpk_dk(DK);\n",
+"D=poly(z,'s','roots')/poly(p,'s','roots')\n",
+"\n",
+"evans(Gs*D)\n",
+"zoom_rect([-8 -9 3 9])\n",
+"\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus for DC servo pole assignment','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.31: Reduced_Order_Estimatortor_Design_for_DC_Servo.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.31\n",
+"// Reduced-Order Estimator Design for DC Servo.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"//Transfer function model for DC Servo\n",
+"s=poly(0,'s');\n",
+"num=10;\n",
+"den=s*(s+2)*(s+8);\n",
+"Gs=syslin('c',num/den);\n",
+"// State space representation\n",
+"F=[-10 1 0;-16 0 1;0 0 0]\n",
+"G=[0 0 10]';\n",
+"H=[1 0 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//Desired poles for the DC Servo system.\n",
+"Pc=[-1.42 -1.04+2.14*%i -1.04-2.14*%i ]\n",
+"// State feedback gain\n",
+"K=ppol(F,G,Pc)\n",
+"disp(K,'K=','State feedback gain')\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Estimator - error roots are at\n",
+"//partioned system\n",
+"Faa=F(1,1); Fab=F(1,2:3);\n",
+"Fba=F(3,1); Fbb=F(2:3,2:3);\n",
+"Ga=G(1);Gb=G(2:3);\n",
+"\n",
+"Pe=[-4.24+4.24*%i, -4.24-4.24*%i]\n",
+"// Observer gain matrix for system \n",
+"L=ppol(Fbb',Fab',Pe);\n",
+"L=L';\n",
+"disp(L,'L=' );\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//State feedback control law u=-Kx=-(K+[L*k2 0])[y xc]'; \n",
+"k1=K(1); k2=K(2:3);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//compensator transfer function\n",
+"s=poly(0,'s');\n",
+"num=(-0.735+s)*(1.871+s);\n",
+"den=poly([-0.990 + 6.12* %i, -0.990 - 6.12* %i] ,'s','roots')\n",
+"Dcr=syslin('c',num/den);\n",
+"disp(Dcr,'Dcr','compensator transfer function')\n",
+"//------------------------------------------------------------------\n",
+"//Root locus with reduced order compensator\n",
+"evans(-Dcr*Gs)\n",
+"zoom_rect([-8 -9 3 9])\n",
+"\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus for DC servo reduced order controller','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.32: Redesign_of_the_Dc_servo_compensator_using_SRL.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.32\n",
+"// Redesign of the Dc servo compensator using SRL\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"//Transfer function model for DC Servo\n",
+"s=poly(0,'s');\n",
+"num=10;\n",
+"den=s*(s+2)*(s+8);\n",
+"Gs=syslin('c',num/den);\n",
+"\n",
+"// State space representation\n",
+"F=[-10 1 0;-16 0 1;0 0 0]\n",
+"G=[0 0 10]';\n",
+"H=[1 0 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//Desired poles for the DC Servo system.\n",
+"Pc=[-2+1.56*%i -2-1.56*%i -8.04]\n",
+"\n",
+"\n",
+"// State feedback gain\n",
+"K=ppol(F,G,Pc)\n",
+"disp(K,'K=','State feedback gain')\n",
+"\n",
+"//Estimator - error roots are at\n",
+"Pe=[-4+4.49*%i -4-4.49*%i -9.169]\n",
+"exec .\acker_dk.sci;\n",
+"Lt=ppol(F',H',Pe);\n",
+"L=clean(Lt');\n",
+"disp(L,'L=','Observer gain')\n",
+"//Error in book, Gain values are different in book.\n",
+"//------------------------------------------------------------------\n",
+"//Compensator Design\n",
+"DK=-K*inv(s*eye(n,n)-F+G*K+L*H)*L;\n",
+"DK=syslin('c',DK)\n",
+"exec('./zpk_dk.sci', -1);\n",
+"[pl,zr,Kp]=zpk_dk(DK);\n",
+"Dc=poly(zr,'s','roots')/poly(pl,'s','roots')\n",
+"//------------------------------------------------------------------\n",
+"//symmetric root locus \n",
+"G_s=horner(Gs,-s);\n",
+"evans(Gs*G_s)\n",
+"zoom_rect([-10 -5 10 5])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Symmetric root locus','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//root locus \n",
+"figure,\n",
+"evans(Gs*Dc) //Correct root locus\n",
+"zoom_rect([-11 -6 1 6])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus for pole assignment from the SRL','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Discrete-time controller\n",
+"nc=94.5*conv([7.98 1],[2.52 1])\n",
+"dc=conv([59.5348 8.56 1],[10.6 1])\n",
+"sysDc=poly(nc,'s','coeff')/poly(dc,'s','coeff');\n",
+"sysDc_ss=syslin('c',tf2ss(sysDc));\n",
+"ts=0.1;\n",
+"sysDd=dscr(sysDc_ss,ts)\n",
+"Gdz=ss2tf(sysDd);\n",
+"\n",
+"disp(sysDc,'Continuous-time compensator')\n",
+"disp(Gdz,'Discrete-time compensator')\n",
+"//------------------------------------------------------------------\n",
+"//step responses\n",
+"importXcosDiagram('.\Ex7_32_model.xcos')\n",
+"\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"figure,\n",
+"plot(yt.time,yt.values(:,1),2)\n",
+"plot(yt.time,yt.values(:,2),'r--')\n",
+"xlabel('Time (sec)');\n",
+"ylabel('y');\n",
+"title('Comaprison of step responses for continuous and discrete...\n",
+" controllers','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller',4)\n",
+"\n",
+"//Control inputs\n",
+"figure,\n",
+"plot(ut.time,ut.values(:,1),2)\n",
+"plot(ut.time,ut.values(:,2),'r--')\n",
+"xlabel('Time (sec)');\n",
+"ylabel('u');\n",
+"title('Comaprison of control signals for continuous and discrete...\n",
+" controllers','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller')\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.33: DC_servo_system_redesign_with_modified_with_dominant_second_order_pole_locations.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.33\n",
+"// DC servo system redesign with modified with dominant second\n",
+"// order pole locations.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"//Transfer function model for DC Servo\n",
+"s=poly(0,'s');\n",
+"num=10;\n",
+"den=s*(s+2)*(s+8);\n",
+"Gs=syslin('c',num/den);\n",
+"\n",
+"// State space representation\n",
+"F=[-10 1 0;-16 0 1;0 0 0]\n",
+"G=[0 0 10]';\n",
+"H=[1 0 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//Desired poles for the DC Servo system.\n",
+"Pc=[-1.41+1.41*%i -1.41-1.41*%i -8]\n",
+"\n",
+"\n",
+"// State feedback gain\n",
+"K=ppol(F,G,Pc)\n",
+"disp(K,'K=','State feedback gain')\n",
+"\n",
+"//Estimator - error roots are at\n",
+"Pe=[-4.24+4.24*%i -4.24-4.24*%i -8]\n",
+"exec .\acker_dk.sci;\n",
+"Lt=ppol(F',H',Pe);\n",
+"L=clean(Lt');\n",
+"disp(L,'L=','Observer gain')\n",
+"//Error in book, Gain values are different in book.\n",
+"//------------------------------------------------------------------\n",
+"//Compensator Design\n",
+"DK=-K*inv(s*eye(n,n)-F+G*K+L*H)*L;\n",
+"DK=syslin('c',DK)\n",
+"exec('./zpk_dk.sci', -1);\n",
+"[pl,zr,Kp]=zpk_dk(DK*10);\n",
+"disp(zr,'zeros',pl,'Poles',Kp*10,'Gain(includung system gain)')\n",
+"Dcs=poly(zr,'s','roots')/poly(pl,'s','roots')\n",
+"disp(Dcs,'Dcs=','Compensator transfer function')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.34: Servomechanism_increasing_the_velocity_constant_through_zero_assignment.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.34\n",
+"// Servomechanism, increasing the velocity constant through\n",
+"// zero assignment. \n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"// State space representation\n",
+"//Transfer function model for DC Servo\n",
+"s=poly(0,'s');\n",
+"num=1;\n",
+"den=s*(s+1);\n",
+"Gs=syslin('c',num/den);\n",
+"\n",
+"// State space representation\n",
+"F=[0 1;0 -1]\n",
+"G=[0 1]';\n",
+"H=[1 0];\n",
+"J=0;\n",
+"n=sqrt(length(F));\n",
+"//Desired poles for the DC Servo system.\n",
+"Pc=[-2 -2]\n",
+"\n",
+"// State feedback gain\n",
+"exec .\acker_dk.sci;\n",
+"K=acker_dk(F,G,Pc)//Gain computed in book is incorrect.\n",
+"disp(K,'K=','State feedback gain')\n",
+"//------------------------------------------------------------------\n",
+"//Overall transfer function with reduced order estimator.\n",
+"Gred=8.32*(0.096+s)/(0.1 +s)/(8 + 4*s+s^2)\n",
+"Gred=syslin('c',Gred)\n",
+"disp(Gred,'Ys/Rs','Overall transfer function with reduced...\n",
+" order estimator')\n",
+"\n",
+"//Compensator\n",
+"D=(0.096+s)*(s+1)/(4.08 +s)/(0.0196+s)\n",
+"Ds=syslin('c',D*8.32)\n",
+"disp(Ds,'Ds=','Compensator transfer function')\n",
+"//------------------------------------------------------------------\n",
+"//root locus \n",
+"figure(0)\n",
+"evans(D*Gs,100) //Correct root locus\n",
+"zoom_rect([-0.2 -0.1 0.1 0.1])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"xset('color',2);\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"title('Root locus of lag-lead compensation','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//Bode plot\n",
+"figure(1)\n",
+"bode(Ds*Gs,0.01/2/%pi,100/2/%pi,'rad') //Correct root locus\n",
+"\n",
+"f=gca();\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"//Title, labels and grid to the figure\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Frequency response of lag-lead compensation','fontsize',3);\n",
+"//------------------------------------------------------------------\n",
+"//step response of the system with lag compensation\n",
+"t=0:0.1:5;\n",
+"ylag=csim('step',t,8.32*Gs*D/(1+8.32*Gs*D));\n",
+"figure\n",
+"plot(t,ylag,2);\n",
+"xlabel('Time (sec)');\n",
+"ylabel('y');\n",
+"title('Step response of the system with lag compensation','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"//Discrete-time controller\n",
+"sysDc_ss=syslin('c',tf2ss(Ds));\n",
+"ts=0.1;\n",
+"sysDd=dscr(sysDc_ss,ts)\n",
+"Gdz=ss2tf(sysDd)\n",
+"\n",
+"disp(Gdz,'Discrete-time compensator')\n",
+"//------------------------------------------------------------------\n",
+"//step responses comparision\n",
+"importXcosDiagram('.\Ex7_34_model.xcos')\n",
+"\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"figure,\n",
+"plot(yt.time,yt.values(:,1),2)\n",
+"plot(yt.time,yt.values(:,2),'r--')\n",
+"xlabel('Time (sec)');\n",
+"ylabel('y');\n",
+"title('Comaprison of step responses for continuous and discrete...\n",
+" controllers','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller',4)\n",
+"\n",
+"//Control inputs\n",
+"figure,\n",
+"plot(ut.time,ut.values(:,1),2)\n",
+"plot(ut.time,ut.values(:,2),'r--')\n",
+"xlabel('Time (sec)');\n",
+"ylabel('u');\n",
+"title('Comaprison of control signals for continuous and discrete...\n",
+" controllers','fontsize',3)\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"legend('continuous controller','digital controller')\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.35: Integral_Control_of_a_Motor_Speed_System.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.35\n",
+"// Integral Control of a Motor Speed System\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"\n",
+"//Transfer function model \n",
+"num=1;\n",
+"s=poly(0,'s');\n",
+"den=(s+3);\n",
+"G=syslin('c',num/den);\n",
+"sys=tf2ss(G)\n",
+"\n",
+"// State space representation of augmented system\n",
+"F=[0 1; 0 -3];\n",
+"G=[0 1]'\n",
+"H=[1 0];\n",
+"J=0;\n",
+"\n",
+"//Desired poles for augmented system\n",
+"Pc=[-5 -5]\n",
+"\n",
+"// State feedback gain is\n",
+"K=ppol(F,G,Pc)\n",
+"disp(K,'K=')\n",
+"\n",
+"//Estimator\n",
+"Pe=[-10]\n",
+"L=ppol(sys.A',sys.C',Pe)\n",
+"disp(L','L=')\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//(c) Compare step reference and disturbance response.\n",
+"//step reference response switch r=1 and w=0;\n",
+"r=1;w=0;\n",
+"importXcosDiagram('.\Ex7_35_model.xcos')\n",
+" //The diagram data structure\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"figure(0)\n",
+"plot(yt.time,yt.values)\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"\n",
+"figure(1)\n",
+"plot(ut.time,ut.values)\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"//------------------------------------------------------------------\n",
+"// Step disturbance response switch r=0 and w=1;\n",
+"w=1;r=0;\n",
+"importXcosDiagram('.\Ex7_35_model.xcos')\n",
+" //The diagram data structure\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"\n",
+"scf(0)\n",
+"plot(yt.time,yt.values,'r--')\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"title('step Response','fontsize',3)\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"legend('y1','y2')\n",
+"xset('font size',3);\n",
+"xstring(0.9,0.9,'$y_1$');\n",
+"xstring(0.25,0.12,'$y_2$');\n",
+"\n",
+"\n",
+"scf(1)\n",
+"plot(ut.time,ut.values,'r--')\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"title('Control efforts','fontsize',3)\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"legend('u1','u2')\n",
+"xset('font size',3);\n",
+"xstring(0.25,2.5,'$u_1$');\n",
+"xstring(1,-1,'$u_2$');\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.7: Analog_computer_Implementation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.7\n",
+"//Analog computer Implementation.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space model of the given system\n",
+"F=[-6 -11 -6; 1 0 0; 0 1 0];\n",
+"G=[6; 0; 0];\n",
+"H=[0 0 1];\n",
+"J=0;\n",
+"sys_ss=syslin('c',F,G,H,J)\n",
+"disp(sys_ss)\n",
+"//------------------------------------------------------------------\n",
+"//Transfer function form\n",
+"[d,Ns,Ds]=ss2tf(sys_ss)\n",
+"Ns=clean(Ns);\n",
+"G=syslin('c',Ns/Ds);\n",
+"disp(G)\n",
+"//------------------------------------------------------------------\n",
+"// convert numerator - denominator to pole - zero form\n",
+"//gain (K) pole (P) and zeros (Z) of the system\n",
+"temp=polfact(Ns);\n",
+"Z=roots(Ns); //locations of zeros\n",
+"P=roots(Ds); //locations of poles\n",
+"K=temp(1); //first entry is always gain\n",
+"disp( K,'Gain', P, 'Poles',Z,'Zeros',)\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.8: Time_scaling_an_oscillator.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.8\n",
+"//Time scaling an oscillator.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space model of an oscillator\n",
+"wn=15000 // rad/sec\n",
+"F=[0 1;wn^2 0];\n",
+"G=[0;10^6];\n",
+"disp(G,'G',F,'F','Given system');\n",
+"//------------------------------------------------------------------\n",
+"// State space model of the time-scaled system for \n",
+"// a millisecond scale w0=1e3;\n",
+"w0=1e3; //rad/sec\n",
+"F1=F/w0;\n",
+"G1=G/w0;\n",
+"disp(G1,'G1',F1,'F1','Time scaled system in mm');\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7.9: State_Equations_in_Modal_Canonical_Form.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 7.9\n",
+"//State Equations in Modal Canonical Form.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function \n",
+"s=poly(0,'s');\n",
+"g1=1/s^2;\n",
+"g2=-1/(s^2+2*s+4);\n",
+"Gs=g1+g2;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation in modal canonical form\n",
+"sys1=tf2ss(g1);\n",
+"sys2=tf2ss(g2);\n",
+"[F1,G1,T1]=canon(sys1.A, sys1.B)\n",
+"H1=sys1.C*T1;\n",
+"\n",
+"[F2,G2,T2]=canon(sys2.A, sys2.B)\n",
+"H2=sys2.C*T2;\n",
+"\n",
+"F=[F1 zeros(2,2);zeros(2,2) F2];\n",
+"G=[G1;G2];\n",
+"H=[H1,H2];\n",
+"J=0;\n",
+"disp(J,'J',H,'H',G,'G',F,'F','System in modal canonical form')\n",
+"//------------------------------------------------------------------\n",
+" //As Y=G*U; consatnts k1 and k2 are taken out from G1 and G2 will be \n",
+" //multiplied to H1 and H2 \n",
+"\n",
+"// So alternately, it can be reprsented as\n",
+"k1=-1;k2=-2;\n",
+"F=[F1 zeros(2,2);zeros(2,2) F2];\n",
+"G=[G1/k1;G2/k2];\n",
+"H=[H1*k1,H2*k2];\n",
+"J=0;\n",
+"disp(J,'J',H,'H',G,'G',F,'F','System in modal canonical form')\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/8-Digital_Control.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/8-Digital_Control.ipynb
new file mode 100644
index 0000000..b90dd7b
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/8-Digital_Control.ipynb
@@ -0,0 +1,174 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 8: Digital Control"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8.1: Digital_Controller_using_tustin_approximation.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"///Example 8.1\n",
+"// Digital Controller using tustin approximation.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Cntroller\n",
+"s=poly(0,'s');\n",
+"numD=s/2+1;\n",
+"denD=s/10+1;\n",
+"D=10*numD/denD;\n",
+"Ds=syslin('c',D);\n",
+"//sampling freq. = 25 times bandwidth\n",
+"Wbw=10;\n",
+"Ws=25*Wbw;\n",
+"fs=Ws/2/%pi;\n",
+"T=1/fs; //sampling time\n",
+"a=1;b=-1;\n",
+"c=1;d=1;\n",
+"//Digital controller\n",
+"z=poly(0,'z');\n",
+"Dz=horner(Ds,2/T*(a*z+b)/(c*z+d));\n",
+"disp(Dz,'Digital Controller : ')\n",
+"//------------------------------------------------------------------\n",
+"//step response and control efforts.\n",
+"figure(0);\n",
+"importXcosDiagram('.\Ex8_1_model.xcos')\n",
+" //The diagram data structure\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values(:,1),'r--')\n",
+"plot(yt.time,yt.values(:,2),2)\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Position, y');\n",
+"title(['Comparison between digital and continuous controller step...\n",
+" response';'with a sample rate 25 times bandwidth';'(a) Position '],...\n",
+" 'fontsize',3);\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"//control effort\n",
+"figure(1);\n",
+"plot(ut.time,ut.values(:,1),'r--')\n",
+"plot2d2(ut.time,ut.values(:,2),2)\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Control, u');\n",
+"title(['Comparison between digital and continuous controller step...\n",
+" response';'with a sample rate 25 times bandwidth';'(b) Control '],...\n",
+" 'fontsize',3);\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8.2: Design_of_a_Space_Station_Attitude_Digital_Controller_using_Discrete_Equivalents.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 8.2\n",
+"// Design of a Space Station Attitude Digital Controller using\n",
+"// Discrete Equivalents\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"// State space representation of continuous time system\n",
+"s=poly(0,'s');\n",
+"num=1;\n",
+"den=(s^2);\n",
+"Gs=syslin('c',num/den);\n",
+"Ds=0.81*(s+0.2)/(s+2);\n",
+"Ds=syslin('c',Ds);\n",
+"sysc=Gs*Ds;\n",
+"//Root locus\n",
+"evans(sysc)\n",
+"zoom_rect([-2 -0.4 0.5 0.4])\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('s-plane locus with respect to K','fontsize',3)\n",
+"//------------------------------------------------------------------\n",
+"//Contonuous time response of the system\n",
+"figure,\n",
+"tc=0:0.1:30;\n",
+"syscl=sysc/(1+sysc)\n",
+"yc=csim('step',tc,syscl);\n",
+"plot(tc,yc,'b')\n",
+"//------------------------------------------------------------------\n",
+"// Discretization of the system at\n",
+"z=poly(0,'z')\n",
+"// sampling time Ts=1 sec\n",
+"Ts=1;\n",
+"Dz1=horner(Ds,2/Ts*(z-1)/(z+1))\n",
+"disp(Dz1,'Dz1=','Discrete-time controller with Ts=1 sec.')\n",
+"// sampling time Ts=0.5 sec\n",
+"Ts2=0.5;\n",
+"Dz2=horner(Ds,2/Ts2*(z-1)/(z+1))\n",
+"disp(Dz2,'Dz2=','Discrete-time controller with Ts=0.5 sec.')\n",
+"//discrete-time response of the system.\n",
+"importXcosDiagram('.\Ex8_2_model.xcos')\n",
+" //The diagram data structure\n",
+"xcos_simulate(scs_m,4);\n",
+"//scs_m.props.context\n",
+"plot(yt1.time,yt1.values,'m-.') //with Ts=1sec.\n",
+"plot(yt2.time,yt2.values,'r--') //with Ts=0.5 sec.\n",
+"//------------------------------------------------------------------------------\n",
+"title('step responses of continous and digital implementations','fontsize',3)\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"xlabel('Time (sec)','fontsize',2)\n",
+"ylabel('Plant output','fontsize',2)\n",
+"legend('Continuous design','Discrete equivalent design, T=1 sec.'...\n",
+",'Discrete equivalent design, T=0.5 sec.',4)\n",
+"//------------------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/9-Nonlinear_Systems.ipynb b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/9-Nonlinear_Systems.ipynb
new file mode 100644
index 0000000..8d78e32
--- /dev/null
+++ b/Feedback_Control_of_Dynamic_Systems_by_G_F_Franklin/9-Nonlinear_Systems.ipynb
@@ -0,0 +1,638 @@
+{
+"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 9: Nonlinear Systems"
+ ]
+ },
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.11: Describing_Function_for_a_relay_with_hysteresis_non_linearity.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.11\n",
+"//Describing Function for a relay with hysteresis nonlinearity.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Response of the saturation noninearity to sinusoidal input\n",
+"figure;\n",
+"importXcosDiagram('.\Ex9_11_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values(:,1),'r--')\n",
+"plot(yt.time,yt.values(:,2),'b')\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Amplitude');\n",
+"title('Relay with hysteresis nonlinearity output to sinusoidal...\n",
+" input','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([0 -1.2 5 1.2])\n",
+"//------------------------------------------------------------------\n",
+"////Describing Functin for relay with hysteresis nonlinearity.\n",
+"h=0.1;\n",
+"N=1;\n",
+"i=1;\n",
+"\n",
+"for a=0.1:0.025:1\n",
+" if a<h then\n",
+" Keq(i,1)=0;\n",
+" ro(i,1)=0;\n",
+" theta(i,1)=0\n",
+" else\n",
+" Keq(i,1)=4*N/(%pi*a)*(sqrt(1-(h/a)^2)-%i*h/a)\n",
+" [r th]=polar(Keq(i,1));\n",
+" ro(i,1)=r; //magnitude\n",
+" theta(i,1)=clean(th); //angle in radians\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"\n",
+"a=0.1:0.025:1\n",
+"a=a';\n",
+"figure,\n",
+"\n",
+"subplot(2,1,1), plot(a,ro)\n",
+"xlabel('$a$');\n",
+"ylabel(['Magnitude', '$|K_{eq}|$']);\n",
+"\n",
+"xset('font size',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"title('Describing Functin for relay with hysteresis nonlinearity...\n",
+" with h=0.1 and N=1','fontsize',3);\n",
+"\n",
+"subplot(2,1,2), plot(a,theta*180/%pi)\n",
+"xlabel('$a$');\n",
+"ylabel(['Phase', '$ \angle K_{eq}$','deg.']);\n",
+"xset('font size',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.12: Conditionally_stable_system.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.12\n",
+"//Conditionally stable system.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"num=0.1;\n",
+"den=(s^2+0.2*s+1)*(s);\n",
+"Gs=syslin('c',num/den)\n",
+"\n",
+"//Nyquist plot of the system\n",
+"nyquist(Gs,0.035,10)\n",
+"title('Nyquist plot and describing function to determine limit...\n",
+" cycle','fontsize',3);\n",
+"\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"xset('color',2);\n",
+"\n",
+"// Nyquist Plot of Describing Function for saturation nonlinearity. \n",
+"omegat=0.05:0.05:%pi;\n",
+"a=sin(omegat);\n",
+"N=0.1;\n",
+"k=1; \n",
+"\n",
+"Keq=2/%pi*(k*asin(N ./a /k)+N ./a .* sqrt(1-(N/k ./a) .^2));\n",
+"DF_nyq=-1 ./Keq; \n",
+"\n",
+"plot(DF_nyq,zeros(1,length(DF_nyq)),'m-.')\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([-0.8 -0.5 0.2 0.5])\n",
+"\n",
+"//limit cycle points\n",
+"plot(-0.5,0,'bo');\n",
+"\n",
+"xset('font size',3)\n",
+"xstring(-0.78,0.08,'limit cycle point');\n",
+"xarrows([-0.6;-0.52],[0.1;0.02],-1)\n",
+"xstring(-0.62,-0.22,'$-\frac{1}{K_{eq}$');\n",
+"xarrows([-0.55;-0.55],[-0.1;0],-1)\n",
+"//------------------------------------------------------------------\n",
+"//Describing Functin for saturation nonlinearity.\n",
+"Keq=[]\n",
+"i=1;\n",
+"\n",
+"for a=0:0.2:10\n",
+" if k*a/N > 1 then\n",
+" Keq(i,1)=2/%pi*(k*asin(N/a/k)+N/a*sqrt(1-(N/k/a)^2))\n",
+" else\n",
+" Keq(i,1)=k\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"\n",
+"a=0:0.2:10;\n",
+"a=a';\n",
+"\n",
+"figure,\n",
+"plot(a,Keq)\n",
+"xlabel('$a$');\n",
+"ylabel('$K_{eq}$');\n",
+"\n",
+"xset('font size',3);\n",
+"title('Describing Function for a saturation nonlinearity...\n",
+" with N=0.1 and k=1','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([0 0 10 1.1])\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.13: Determination_of_stability_with_a_hysteresis_nonlinearity.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.13\n",
+"//Determination of stability with a hysteresis nonlinearity.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System Model\n",
+"s=poly(0,'s');\n",
+"num=1;\n",
+"den=(s^2+s);\n",
+"Gs=syslin('c',num/den);\n",
+"//------------------------------------------------------------------\n",
+"//Nyquist Plot of the system\n",
+"nyquist(Gs,0.25,3) \n",
+"\n",
+"// Nyquist Plot of Describing Function for hysteresis nonlinearity\n",
+"N=1;\n",
+"h=0.1; \n",
+"i=1;\n",
+"\n",
+"for omegat=0:0.05:%pi-0.1;\n",
+" a=sin(omegat);\n",
+" DF_nyq(i,1)=-%pi/4/N*(sqrt(a^2-h^2) + h * %i)\n",
+" i=i+1;\n",
+"end\n",
+"\n",
+"plot(real(DF_nyq),imag(DF_nyq),'m-.')\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"zoom_rect([-0.3 -0.3 0 0.3])\n",
+"title('Nyquist plot of system and describing function to...\n",
+" determine limit cycle','fontsize',3)\n",
+"\n",
+"//limit cycle points\n",
+"plot(-0.1714,-0.0785,'ro');\n",
+"xstring(-0.25,0,'limit cycle point');\n",
+"xarrows([-0.2;-0.172],[0;-0.077],-1);\n",
+"\n",
+"//------------------------------------------------------------------\n",
+"//Response of the system\n",
+"K=2;\n",
+"r=1\n",
+"figure(1);\n",
+"importXcosDiagram('.\Ex9_13_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values)\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Output, y');\n",
+"title('Step response displaying limit cycle oscillations','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.5: Changing_Overshoot_and_Saturation_nonlinearity.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.5\n",
+"//Changing Overshoot and Saturation nonlinearity.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"num=(s+1)\n",
+"den=(s^2);\n",
+"Gs=syslin('c',num/den)\n",
+"\n",
+"//Root locus\n",
+"evans(Gs,5)\n",
+"title(['Root locus of', '$(s+1)/(s^2)$','with saturation removed'],...\n",
+"'fontsize',3);\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"// Step response\n",
+"K=1;\n",
+"i=[2 4 6 8 10 12];\n",
+"figure(1);\n",
+"importXcosDiagram('.\Ex9_5_model.xcos')\n",
+"\n",
+"for r=i\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values)\n",
+"end\n",
+"\n",
+"xlabel('time');\n",
+"ylabel('y');\n",
+"title('Step response of the system for various input sizes','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"\n",
+"xset('font size',3);\n",
+"xstring(4,2.5,'$r=2$');\n",
+"xstring(6,5.5,'$4$');\n",
+"xstring(8,8.7,'$6$');\n",
+"xstring(10,12.2,'$8$');\n",
+"xstring(12,15.4,'$10$');\n",
+"xstring(14,18.4,'$12$');\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.6: Stability_of_conditionally_stable_system_using_root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.6\n",
+"//Stability of conditionally stable system using root locus.\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"num=(s+1)^2\n",
+"den=(s^3);\n",
+"Gs=syslin('c',num/den)\n",
+"//Root locus\n",
+"evans(Gs,7)\n",
+"title(['Root locus for', '$(s+1)^2/(s^3)$','for system'],...\n",
+"'fontsize',3);\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"//Response of the system\n",
+"K=2;\n",
+"i=[1 2 3 3.475];\n",
+"figure(1);\n",
+"\n",
+"importXcosDiagram('.\Ex9_6_model.xcos')\n",
+"\n",
+"for r=i\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values)\n",
+"end\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Amplitude');\n",
+"title('Step response of the system','fontsize',3);\n",
+"\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"xset('font size',3);\n",
+"xstring(3,6.5,'$r=3.475$');\n",
+"xstring(2.5,5.2,'$3$');\n",
+"xstring(2,3,'$2$');\n",
+"xstring(1,1.4,'$1$');\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.7: Analysis_and_design_of_the_system_with_limit_cycle_using_the_root_locus.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.7\n",
+"//Analysis and design of the system with limit cycle using the root locus. \n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System transfer function and its root locus \n",
+"\n",
+"s=poly(0,'s');\n",
+"num=0.1;\n",
+"den=(s^2+0.2*s+1)*(s);\n",
+"Gs=syslin('c',num/den);\n",
+"\n",
+"//Root locus\n",
+"evans(Gs,40)\n",
+"title(['Root locus of', '$(0.1/s(s^2+0.2*s+1)$'],'fontsize',3);\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"//Response of the system\n",
+"figure;\n",
+"//Response of the system\n",
+"K=0.5;\n",
+"i=[1 4 8];\n",
+"importXcosDiagram('.\Ex9_7_model.xcos')\n",
+"\n",
+"for r=i\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values)\n",
+"end\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Amplitude');\n",
+"title('Step response of the system','fontsize',3);\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"zoom_rect([0 0 150 9])\n",
+"\n",
+"xset('font size',3);\n",
+"xstring(80,1.6,'$r=1$');\n",
+"xstring(80,4.6,'$r=4$');\n",
+"xstring(80,8.2,'$r=8$');\n",
+"//------------------------------------------------------------------\n",
+"//System with notch compensation\n",
+"D=123*(s^2+0.18*s+0.81)/(s+10)^2;\n",
+"\n",
+"//Root locus\n",
+"figure,\n",
+"evans(Gs*D,40)\n",
+"title(['Root locus including notch compensation'],'fontsize',3);\n",
+"f=gca();\n",
+"f.x_location = 'origin'\n",
+"f.y_location = 'origin'\n",
+"h=legend('');\n",
+"h.visible = 'off'\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([-14 -2 2 2])\n",
+"//------------------------------------------------------------------\n",
+"//Response of the system witth notch filter\n",
+"figure;\n",
+"K=0.5;\n",
+"i=[2 4];\n",
+"importXcosDiagram('.\Ex9_7_model_notch.xcos')\n",
+"\n",
+"for r=i\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values)\n",
+"end\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Amplitude');\n",
+"title('Step response of the system with notch filter','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"xset('font size',3);\n",
+"xstring(30,2.2,'$r=2$');\n",
+"xstring(34,3.75,'$r=4$');\n",
+"//------------------------------------------------------------------\n",
+"\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.8: Antiwindup_compensation_for_a_PI_controller.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.8\n",
+"//Antiwindup compensation for a PI controller.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//System Model\n",
+"\n",
+"//Response of the system\n",
+"kp=2;\n",
+"ki=4;\n",
+"\n",
+"//Without antiwindup\n",
+"ka=0;\n",
+"importXcosDiagram('.\Ex9_8_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"figure(0)\n",
+"plot(yt.time,yt.values,'m-.')\n",
+"figure(1)\n",
+"plot(ut.time,ut.values,'m-.')\n",
+"\n",
+"//With antiwindup\n",
+"ka=10;\n",
+"xcos_simulate(scs_m,4);\n",
+"scf(0)\n",
+"plot(yt.time,yt.values)\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Output');\n",
+"title('Integrator antiwindup (a) step response.','fontsize',3);\n",
+"\n",
+"\n",
+"scf(1)\n",
+"plot(ut.time,ut.values);\n",
+"exec .\fig_settings.sci; // custom script for setting figure properties\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Control');\n",
+"title('Integrator antiwindup (b) Control effort.','fontsize',3);\n",
+"zoom_rect([0 -1.2 10 1.2])\n",
+"\n",
+"//------------------------------------------------------------------\n",
+""
+ ]
+ }
+,
+{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9.9: Describing_Function_for_a_saturation_nonlinearity.sce"
+ ]
+ },
+ {
+"cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+"source": [
+"//Example 9.9\n",
+"//Describing Function for a saturation nonlinearity.\n",
+"\n",
+"xdel(winsid())//close all graphics Windows\n",
+"clear;\n",
+"clc;\n",
+"//------------------------------------------------------------------\n",
+"//Response of the saturation nonlinearity to sinusoidal input\n",
+"figure;\n",
+"importXcosDiagram('.\Ex9_9_model.xcos')\n",
+"xcos_simulate(scs_m,4);\n",
+"scs_m.props.context\n",
+"plot(yt.time,yt.values(:,1),'r--')\n",
+"plot(yt.time,yt.values(:,2),'b')\n",
+"\n",
+"xlabel('Time (sec.)');\n",
+"ylabel('Amplitude');\n",
+"title('Saturation nonlinearity output to sinusoidal input',...\n",
+"'fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"//------------------------------------------------------------------\n",
+"//Describing Functin for saturation nonlinearity.\n",
+"k=1;\n",
+"N=1;\n",
+"i=1;\n",
+"Keq=[];\n",
+"\n",
+"for a=0:0.2:10\n",
+" if k*a/N > 1 then\n",
+" Keq(i,1)=2/%pi*(k*asin(N/a/k)+N/a*sqrt(1-(N/k/a)^2))\n",
+" else\n",
+" Keq(i,1)=k\n",
+" end\n",
+" i=i+1;\n",
+"end\n",
+"\n",
+"a=0:0.2:10;\n",
+"a=a';\n",
+"figure,\n",
+"plot(a,Keq)\n",
+"xlabel('$a$');\n",
+"ylabel('$K_{eq}}$');\n",
+"\n",
+"xset('font size',3);\n",
+"title('Describing Function for a saturation nonlinearity...\n",
+" with k=N=1','fontsize',3);\n",
+"exec .\fig_settings.sci; //custom script for setting figure properties\n",
+"zoom_rect([0 0 10 1.1])\n",
+"//------------------------------------------------------------------"
+ ]
+ }
+],
+"metadata": {
+ "kernelspec": {
+ "display_name": "Scilab",
+ "language": "scilab",
+ "name": "scilab"
+ },
+ "language_info": {
+ "file_extension": ".sce",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "scilab",
+ "version": "0.7.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}