📄 control_system_toolbox.htm
字号:
<!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HoTMetaL PRO 4.0::19970714::extensions to HTML 4.0//EN" "hmpro4.dtd"> <HTML> <HEAD><STYLE TYPE="text/css">h1 { text-align: left; color: #750075 }h2 {text-align:left; color: green} h3 { text-align: left; color: #CC0000 }h4 {text-align:left; color: blue}table {background:#FFFF80}body {background-color: #CACACA} </STYLE><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"> <META NAME="keywords" CONTENT="tutorial, introduction, matlab, control, system, toolbox, control system toolbox, models"><META NAME="description" CONTENT="Tutorial for Control System Toolbox for MATLAB by Finn Haugen, TechTeach."><TITLE>Tutorial for Control System Toolbox for MATLAB by Finn Haugen, TechTeach</TITLE></HEAD> <BODY><TABLE BORDER="0" WIDTH="640" BGCOLOR="#FFFFFF" BORDERCOLOR="#FFFFFF"CELLSPACING="0" CELLPADDING="10" style="border:1px solid #000000;"> <TR> <TD BGCOLOR="#FFFFFF" style="padding-left: 10; padding-right: 10; padding-top: 10; padding-bottom: 10"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; background-color: #FFFFFF" bordercolor="#111111" width="100%" id="AutoNumber1"> <tr> <td width="50%"><a href="http://techteach.no"><img border="0" src="../../logo/logomedtekst.png" width="225" height="52"></a></td> <td width="50%"> <p align="right"> </td> </tr></table><hr><p>More free stuff from TechTeach:</p> <ul> <li><a href="../../kybsim/index_eng.htm">KYBSIM</a> - free simulators, ready to run! </li> <li> <a href="../discretetime_signals_systems/discrete.pdf">Introduction to discrete-time signals and systems</a></li> <li> <a href="../labview">Much LabVIEW stuff!</a></li></ul> <hr><h2 ALIGN="left" style="text-align: center">Tutorial for</h2><H1 ALIGN="left" style="text-align: center">Control System Toolbox for MATLAB</H1><P ALIGN="CENTER">by </P><P ALIGN="CENTER"><A HREF="http://www.techteach.no/adm/fh"><I><FONTCOLOR="#0000ff">Finn Haugen</FONT></I></A></P><P ALIGN="CENTER"><BR><i>October 11, 2003</i></P><P ALIGN="CENTER"><FONT SIZE="-1">This publication can be downloaded and copiedfreely, but reference to the source is appreciated.</FONT></P><HR><H2><EM>Contents:</EM></H2><P><A HREF="#c1"><FONT COLOR="#0000ff">1</FONT></A><B> Introduction</B><br><A HREF="#c2"><FONT COLOR="#0000ff">2</FONT></A><B> Creating and handlingLTI-models (Linear Time-Invariant)</B><br><A HREF="#c21"><FONT COLOR="#0000ff">2.1</FONT></A><FONT SIZE="2"> Creatingmodels</FONT><br><A HREF="#c22"><FONT COLOR="#0000ff">2.2</FONT></A><FONT SIZE="2">Extracting subsystems</FONT><br><A HREF="#c23"><FONT COLOR="#0000ff">2.3</FONT></A><FONT SIZE="2"> Settingand accessing LTI-properties</FONT><br><A HREF="#c24"><FONT COLOR="#0000ff">2.4</FONT></A><FONT SIZE="2">Conversion between state-space models and transfer functions</FONT><br><A HREF="#c25"><FONT COLOR="#0000ff">2.5</FONT></A><FONT SIZE="2">Conversion between continuous-time and discrete-time models</FONT><br><A HREF="#c26"><U><FONT COLOR="#0000ff">2.6</FONT></U></A><FONT SIZE="2">Combining models (series, parallel, and feedback)</FONT><br><A HREF="#c3"><FONT COLOR="#0000ff">3</FONT></A><B> Model analysis tools</B> <br><A HREF="#c31"><FONT COLOR="#0000ff">3.1</FONT></A><FONT SIZE="2">Simulation (time response)</FONT><br><A HREF="#c32"><FONT COLOR="#0000ff">3.2</FONT></A><FONT SIZE="2"> Poles,eigenvalues, and zeros</FONT><br><A HREF="#c33"><FONT COLOR="#0000ff">3.3</FONT></A><FONT SIZE="2"> Frequencyresponse</FONT><br><A HREF="#c34"><FONT COLOR="#0000ff">3.4</FONT></A><FONT SIZE="2"> Stabilityanalysis based on frequency response </FONT><br><A HREF="#c35"><FONT COLOR="#0000ff">3.5</FONT></A><FONT SIZE="2">Pade-approximations</FONT><br><A HREF="#c36"><FONT COLOR="#0000ff">3.6</FONT></A><FONT SIZE="2"> TheLTI-viewer</FONT><br><A HREF="#c4"><FONT COLOR="#0000ff">4</FONT></A><B> Controller design tools</B><br><A HREF="#c41"><FONT COLOR="#0000ff">4.1</FONT></A><FONT SIZE="2"> Rootlocus </FONT><br><A HREF="#c42"><FONT COLOR="#0000ff">4.2</FONT></A><FONT SIZE="2"> Poleplacement </FONT><br><A HREF="#c43"><FONT COLOR="#0000ff">4.3</FONT></A><FONT SIZE="2"> Optimalcontrol</FONT><br><A HREF="#c44"><FONT COLOR="#0000ff">4.4</FONT></A><FONT SIZE="2"> Kalmanestimator (or filter)</FONT><br><A HREF="#c5"><FONT COLOR="#0000ff">5</FONT></A><B> Overview over functions inControl System Toolbox</B><br><HR><H2><A NAME="c1"></A>1 Introduction</H2><P>This text gives an easy guide to Control System Toolbox version 5 whichassumes the installation of MATLAB version 6. </P><P>The text is self-instructive: You are asked to perform a number of simpetasks through which you will learn to master this toolbox, and the expectedresponses are shown in the text.</P><P>It is assumed that you have the basic knowledge about dynamic systems andcontrol theory. It is also assumed that you have basic skills in MATLAB. ForNorwegian users I maysuggest <I><a href="http://techteach.no/publications/matlab">L鎟 MATLAB trinnfor trinn</a></I> (http://techteach.no/publications/matlab). And if you want to simulateyour (control) systems, you may consider using SIMULINK which is based on MATLAB.Tip for Norwegian users: <I><a href="http://techteach.no/publications/simulink">L鎟SIMULINK trinn for trinn</a></I> (http://techteach.no/publications/simulink).</P><P>In the following, CST will be used as an abbreviation for Control SystemToolbox.</P> <hr><H2><A NAME="c2"></A>2 Creating and handling LTI-models (Linear Time-Invariant)</H2><P>The models supported by CST are continuous-time models and discrete-timemodels of the following types: </P><UL><LI>transfer functions </LI><LI>state-space models </LI></UL><P>The CST also supports zero-pole-gain models, but since we will in practicehardly use that model format, it is not described in this text. If you need touse it, you can get information by executing "help zpk". </P><P>The various functions will be introduced via simple examples. </P> <hr><H3><A NAME="c21"></A>2.1 Creating models</H3><P>We will start with continuous-time models, and then take discrete-timemodels. </P><H4>Continuous-time transfer functions</H4><P>The function "tf" creates <I>transfer functions</I>."tf" needs two MATLAB-vectors, one containing the coefficients of the<I>numerator</I> polynomial - taken in descending orders - and one for the<I>denominator</I> polynomial of the transfer function. As an example we willcreate the transfer function </P><P ALIGN="CENTER">H0(s)=K0*s/(T0*s+1)</P><TABLE CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633" BORDER="1"><TR><TD VALIGN="TOP"> <P>K0=2; T0=4; <BR>num0=[K0,0]; den0=[T0,1]; <BR>H0=tf(num0,den0);</P></TD></TR></TABLE><P>To display H0 we execute</P><TABLE CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633" BORDER="1"><TR><TD VALIGN="TOP"> <P> H0</P></TD></TR></TABLE><P>MATLAB's response is </P><BLOCKQUOTE><DL><DT><CODE>Transfer function:</CODE></DT></DL><DL><DT>2 s<BR>-------<BR>4 s + 1</DT></DL></BLOCKQUOTE><P>An LTI-model can contain a <I>time-delay</I>, as in the following model:</P><P ALIGN="CENTER">Hd(s)=[K0*s/(T0*s+1)]e^(-Tdelay*s)</P><P>This system is created by (except from the time-delay term, Hd is equal toH0 defined above):</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>Tdelay=1; <BR>Hd=tf(num0,den0,<FONT COLOR="#800000">'InputDelay'</FONT>,Tdelay)</P></TD></TR></TABLE><P>To display Hd we execute</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>Hd</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P>Transfer function:</P><P>2 s<BR>-------<BR>4 s + 1</P><P>Input delay: 1</P></BLOCKQUOTE><P>The expressions below create a two-input one-output <I>MIMO</I>(Multiple-Input Multple-Output) system of the form</P><P ALIGN="CENTER">y(s)=H1(s) u1(s) + H2(s) u2(s)</P><P>The transfer function can be expressed as </P><P ALIGN="CENTER">H=[H1,H2]</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP" HEIGHT="138"> <P>K1=2; T1=4; num1=[K1,0]; den1=[T1,1];<BR>K2=3; T2=5; num2=[K2]; den2=[T2,1];<BR>Tdelay1=1;<BR>Tdelay2=2;<BR>H1=tf(num1,den1,<FONT COLOR="#800000">'InputDelay'</FONT>,Tdelay1);<BR>H2=tf(num2,den2,<FONT COLOR="#800000">'InputDelay'</FONT>,Tdelay2);<BR>H=[H1,H2];</P></TD></TR></TABLE><P>To display H we execute</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>H</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P>Transfer function from input 1 to output:</P><P> 2 s<BR>exp(-1*s) * -------<BR> 4 s + 1</P><P> 3<BR>exp(-1*s) * -------<BR> 5 s + 1</P></BLOCKQUOTE><P>Note 1: If the system has no time-delay, it is sufficient to writetf(num1,den1).</P><P>Note 2: If the transfer function has the form </P><P ALIGN="CENTER">H(s)=[H1(s)<BR>H2(s)]</P><P>which may correspond to a one-input two-output system, the CST requires thatthe time-delays are equal. </P><P>Suppose we have created a transfer function, and we want to <I>retrieve</I><I>detailed information</I> about the model. The function "tfdate"retreives the information, which is stored in <I>cell arrays</I> (both inSISO-cases and in MIMO-cases). As an example, the following expressionsretreive the polynomials containing the coefficients of the numerator anddenominator polynomials of the (SISO-) transfer function Hd(s) created earlier:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>[numHd,denHd,Ts]=tfdata(Hd)</P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE><DL><DT>numHd=</DT><DT>[1x2 double]</DT><DT>denHd=</DT><DT>[1x2 double]</DT><DT>Ts=</DT><DT>0 </DT></DL></BLOCKQUOTE><P>Here, Ts is the sampling time which is zero for continuous-time models butnon-zero for discrete-time models.</P><P>The response above is not very descriptive since we do not see any numericalvalues for the numerator and denominator coefficients. Suppose we want toretreive these coefficients as <I>vectors</I>. This can be done as follows: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>inputno=1;<BR>outputno=1;<BR>numpolHd=numHd{outputno,inputno}<BR>denpolHd=denHd{outputno,inputno}</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P> numpolHd=<BR>2 0<BR>denpolHd=<BR>4 1</P></BLOCKQUOTE><P>Note: The use of inputno and outputno above can be applied also forMIMO-systems. For example, inputno=3 and outputno=2 corresponds to the transferfunction from input no. 3 to output no. 2 in a MIMO-system. </P><P>Note: The time-delay of Hd(s) was ignored in the data retreival above. </P><H4>Continuous-time state-space models</H4><H5></H5><P> The function "ss" creates linear <I>state-space models </I>havingthe form </P><P ALIGN="CENTER">dx/dt=Ax + Bu</P><P ALIGN="CENTER">y=Cx + Du</P><P>as illustrated in the following example: Given the following state-spacemodel:</P><P ALIGN="CENTER">dx1/dt=x2 </P><P ALIGN="CENTER">dx2/dt=-4*x1 -2*x2 + 2*u</P><P ALIGN="CENTER">y=x1</P><P>This model is created by </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>A=[0,1;-4,-2]; B=[0;2]; C=[1,0]; D=[0];<BR>ss1=ss(A,B,C,D);</P></TD></TR></TABLE><P>To display ss1 we execute</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>ss1</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P><BR>a=</P><P>x1 x2</P><P>x1 0 1.00000</P><DL><DT>x2 -4.00000 -2.00000</DT></DL><P><BR>b=</P><P>u1</P><P>x1 0</P><P>x2 2.00000</P><P><BR>c=</P><P>x1 x2</P><P>y1 1.00000 0</P><P><BR>d=</P><P>u1</P><P>y1 0<BR></P><P></P></BLOCKQUOTE><P>Above, a, b, c, and d, which are default names, are used only for displayingpurposes, and they do in fact not exist in the workspace. To <I>retreive thesystem parameters and give them specific names</I>, we can execute</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>[A1,B1,C1,D1,Ts]=ssdata(ss1)</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P><BR>A1=</P><P>0 1</P><P>-4 -2</P><P><BR>B1=</P><P>0</P><P>2</P><P><BR>C1=</P><P>1 0</P><P><BR>D1=</P><P>0</P><P><BR>Ts=</P><P>0</P></BLOCKQUOTE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -