⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control_system_toolbox.htm

📁 MATLAB中的control tools box
💻 HTM
📖 第 1 页 / 共 4 页
字号:
&quot;c2d&quot;, using the syntax</P><P ALIGN="CENTER">sysdis=c2d(syscont,Ts,method)</P><P>Ts is the sampling time. method is a string telling which discretizingmethod to be used, and the following are available: </P><BLOCKQUOTE>'zoh' for zero order hold. <BR>'foh' for first order hold. <BR>'tustin' for Tustin's method of bilinear transformation. <BR>'prewarp' for Tustin's method with frequency prewarping. <BR>'matched' for the matched pole-zero method. </BLOCKQUOTE><P>As an example, let us discretize a continuous-time model (transfer function)which contains a time-delay, assuming zero order hold: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>K=2; T=4; num=[K,0]; den=[T,1]; Tdelay=1; <BR>Hcont4=tf(num,den,<FONT COLOR="#800000">'Td'</FONT>,Tdelay); <BR>Ts=0.2;<BR>Hdis4=c2d(Hcont4,Ts,'zoh')</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE><BLOCKQUOTE> <P><BR>Transfer function:</P><P>0.5 z - 0.5<BR>----------------<BR>z^6 - 0.9512 z^5</P><P>Sampling time: 0.2</P></BLOCKQUOTE></BLOCKQUOTE><P>(The high order of the denominator is due to the time-delay of thecontinuous-time system.)</P><H4>From discrete-time models to continuous-time models</H4><P>Use the function &quot;d2c&quot;. </P>      <hr><H3> <A NAME="c26"></A>2.6 Combining models (in series, parallel, and feedback)</H3><P>A model can be thought of as a block with inputs and outputs and containinga transfer function or a state-space model inside it. The functions&quot;series&quot;, &quot;parallel&quot;, and &quot;feedback&quot; can be usedto perform basic block-diagram manipulation, as demonstrated in the following.These functions apply to continuous-time models as well as discrete-timesystems.</P><P>As an example, assume given the following transfer functions:</P><P ALIGN="CENTER">Ha(s)=1/(s+2) <BR><BR>Hb(s)=3/(s+4)</P><P>First, let us create the above two systems: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>k1=1; k2=2; k3=3; k4=4;<BR>Ha=tf(k1,[1,k2]);<BR>Hb=tf(k3,[1,k4]); </P></TD></TR></TABLE><P>Let us connect Ha(s) and Hb(s) in <I>series</I>, which means that Hser(s)becomes Ha(s)*Hb(s): </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>Hser=series(Ha,Hb)</P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE> <DL><DT>Transfer function:</DT><DT>3</DT><DT>-------------</DT><DT>s^2 + 6 s + 8</DT></DL></BLOCKQUOTE><P>Below, Ha(s) and Hb(s) are connected in <I>parallel,</I> which means thatHpar(s)=Ha(s)+Hb(s). </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>Hpar=parallel(Ha,Hb)</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <DL><DT>Transfer function:</DT><DT>4 s + 10</DT><DT>-------------</DT><DT>s^2 + 6 s + 8</DT></DL></BLOCKQUOTE><P>Finally, Ha(s) and Hb(s) are connected in a <I>feedback</I> loopwith Ha(s) being in the forward path and Hb(s) being in the feedbackpath: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">feedbsign=-1;Hfeedb=feedback(Ha,Hb,feedbsign)</FONT></P></TD></TR></TABLE><P>Above, feedbsign is the sign of the feedback, and we set it to either -1 (inwhich case it can be omitted) or1. The transfer function Hfeedb(s) is given by </P><P ALIGN="CENTER">Hfeedb(s)=Ha(s)/[1-feedbsign*Ha(s)*Hb(s)]</P><P>MATLAB's response to the expressions above is</P><BLOCKQUOTE> <DL><DT>Transfer function:</DT><DT>s + 4</DT><DT>--------------</DT><DT>s^2 + 6 s + 11</DT></DL></BLOCKQUOTE>      <hr><H2> <A NAME="c3"></A>3 Model analysis tools </H2><P>As a starting point for this chapter, let us define a continuous-timetransfer function, H1c(s), and a discrete-time transfer function, H1d(z) whichwill be the discretized version of H1c(s). We take H1c(s) as </P><P ALIGN="CENTER">H1c(s)=(s+0.5)/(s^2+2s+4)</P><P>and we create H1c(s) with</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">n1=[1,0.5]; d1=[1,2,4]; <BR>H1c=tf(n1,d1)</FONT></P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE> <P><BR>Transfer function:</P><P>s + 0.5<BR>-------------<BR>s^2 + 2 s + 4</P></BLOCKQUOTE><P> Then, let H1d(z) be the zero-order hold discretized version of H1c(s): </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Ts=0.2; <BR>H1d=c2d(H1c,Ts,'zoh')</FONT></P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE> <P><BR>Transfer function:</P><P>0.1692 z - 0.1529</P><P>---------------------</P><P>z^2 - 1.54 z + 0.6703</P><P>Sampling time: 0.2</P></BLOCKQUOTE>      <hr><H3><A NAME="c31"></A>3.1 Simulation (time response)</H3><P>We can simulate the <I>step response</I> of one or several LTI-models with&quot;step&quot;. The input step is then a unit step (the step height is equalto one). Let us simulate both H1c and H1d from t=0 to Tfinal=10 time units:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Tf=10; step(H1c,H1d,Tf)</FONT></P></TD></TR></TABLE><P>The resulting plot is not shown here in this text. </P><P>We can store the simulated time response, y, and the time vector, t, byusing return (or left) arguments:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Tf=10; [y,t]=step(H1d,Tf);</FONT></P></TD></TR></TABLE><P> In this case, no plot will be shown on the screen. Note that only singlesystems can be simulated when you use left-hand arguments, as above, that is&quot;[y,t]=step(H1c,H1d,Tf);&quot; will not work.</P><P>&quot;impulse&quot; simulates the <I>impulse response</I>:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Tf=10; impulse(H1c,Tf)</FONT></P></TD></TR></TABLE><P> The resulting plot is not shown here in this text. </P><P>&quot;initial&quot; simulates the response from the initial state of anLTI-model.</P><P>&quot;lsim&quot; is a more general simulation function as it accepts anyinput signal, not just step or impulse. To generate the input signal, we mayuse &quot;gensig&quot;, which produces a sine wave, or a square wave, orperiodic pulses. Let us as an example simulate H1c with a sinusoidal input, u,having period Tp=0.5, final time Tf=10, and time step Tstep=0.01:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Tp=0.5; Tf=10; Tstep=0.01;[u,t]=gensig('sin',Tp,Tf,Tstep);<BR>lsim(H1c,u,t)</FONT></P></TD></TR></TABLE><P>&nbsp;</P><P><BR>The resulting plot is not shown here in this text. </P><P>Above, &quot;gensig&quot; was used to generate the input signal. Othersignal generators are &quot;square&quot;, &quot;sawtooth&quot;, and&quot;stepfun&quot;. </P>      <hr><H3><A NAME="c32"></A>3.2 Poles, eigenvalues, and zeros</H3><P>We can calculate the poles of an LTI-model with &quot;pole&quot;, as in</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>p=pole(H1c)</P></TD></TR></TABLE><P>MATLAB's response is</P><BLOCKQUOTE> <P>p=</P><P>-1.0000 + 1.7321i</P><P>-1.0000 - 1.7321i</P></BLOCKQUOTE><P>For a state-space model we can analogously calculate the eigenvalues with&quot;eig&quot;.</P><P>&quot;tzero&quot; calulates zeros (transmission zeros for MIMO-models). Hereis an example based on H1c(s):</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">z=tzero(H1c)</FONT></P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE> <P>z=</P><P>-0.5000</P></BLOCKQUOTE><P>With &quot;[pol,zer]=pzmap&quot; we can calculate and plot both the polesand the zeros. Omitting the return-parameters just plots the poles and thezeros in the complex plane: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>pzmap(H1c)</P></TD></TR></TABLE><P>The resulting plot is not shown here in this text. </P><P>Poles and eigenvalues will always be real numbers and/or complex conjugatenumbers. &quot;damp&quot; calculates the relative damping,<FONT FACE="Symbol" SIZE="2">z</FONT> , and the natural (or udamped) resonancefrequency, <FONT FACE="Symbol" SIZE="2">w</FONT> <SUB>0</SUB> for such complexpoles/eigenvalues. It is assumed that the poles or eigenvalues are given as theroots of (the characteristic equation)</P><P ALIGN="CENTER">s<SUP>2 </SUP>+ 2<FONT FACE="Symbol" SIZE="2">z</FONT><FONTSIZE="2"> </FONT><FONT FACE="Symbol" SIZE="2">w</FONT><FONT SIZE="2"><SUB>0</SUB>s + </FONT><FONT FACE="Symbol" SIZE="2">w</FONT><FONT SIZE="2"><SUB>0</SUB><SUP>2</SUP></FONT></P><P>Here is one example:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>damp(H1c)</P></TD></TR></TABLE><P> MATLAB's response is</P><BLOCKQUOTE> <P>Eigenvalue Damping Freq. (rad/s) </P><P>-1.00e+000 + 1.73e+000i 5.00e-001 2.00e+000 </P><P>-1.00e+000 - 1.73e+000i 5.00e-001 2.00e+000</P></BLOCKQUOTE>      <hr><H3> <A NAME="c33"></A>3.3 Frequency response</H3><P>The frequency response of an LTI-model can be calculated with&quot;bode&quot;. Here, &quot;bode&quot; shows the Bode-plots of both H1c andH1d, in the same diagram:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">bode(H1c,H1d)</FONT></P></TD></TR></TABLE><P> The resulting plot is not shown here in this text. Using the syntax </P><P ALIGN="CENTER">[mag,phase,w]=bode(sys)</P><P>the magnitude and the phase (in degrees), and the frequency vector (inrad/s) used by &quot;bode&quot;, are returned. With &quot;bode(sys,w)&quot; theBode-plot will be drawn using our own frequency vector, w. </P><P>The frequency response can be drawn in a Nichols-diagram with&quot;nichols&quot;, and in a Nyquist-diagram with &quot;nyquist&quot;(examples follows in the next section).</P><P>Unfortunately, the Bode-plots are often drawn with very few grid lines, andit may be very difficult to read off precise values from it. To have moregrids, you can do as in the following example (in the example only theamplitude plot is drawn, but similar expressions can be used for the phaseplot):</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">n1=[1]; d1=[1,2,4]; H1=tf(n1,d1);<BR>[mag,phase,w]=bode(H1); <BR>semilogx(w,mag(:));<BR>set(gca,'xtick',[.1,.2,.5,1,2,5,10]);<BR>set(gca,'ytick',[0:0.05:0.4]);<BR>grid</FONT></P></TD></TR></TABLE>      <hr><H3><A NAME="c34"></A>3.4 Stability analysis based on frequency response</H3><P>The function &quot;margin&quot; calculates the stability margins and thecross-over frequencies for a feedback system (continuous-time ordiscrete-time). In the following example &quot;margin&quot; draws a Bode-plotand writes the stability margins and the cross-over frequencies in the diagram.The loop transfer function of the feedback system is </P><P ALIGN="CENTER">Hloop(s)=(K/s)*e<SUP>-Tdel*s</SUP></P><P>where K=0.19, and Tdel=4.17 (time-delay). Let us first create the LTI-objectHloop:</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P>K=0.19; Tdel=4.17; <BR>Hloop=tf(K,[1,0],'InputDelay',Tdel);<br>[Gm,Pm,Wcg,Wcp]=margin(Hloop)</P></TD></TR></TABLE><P> MATLAB's response is</P><P> Gm =<br>1.9826<br>Pm =<br>44.6046<br>Wcg =<br>0.3767<br>Wcp =<br>0.1900 </P><P> Here, Gm is gain margin in dB, Pm is phase margin in degrees, Wcg is cross-over frequency where phase is -180 degrees, and Wcp is cross-over frequency where gain is 1 = 0 dB.</P><p>If you omit the left-hand arguments of &quot;margin&quot;, that is &quot;margin(Hloop)&quot;, a Bode plot of Hloop is presented, with the values of the four above mentioned left-hand arguments of &quot;margin&quot; indicated in the plot.</p><P> Stability analysis can also be performed using a Nyquist-plot or aNichols-plot. Let us try Nichols: </P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> nichols(H1c),ngrid</TD></TR></TABLE><P> Above, ngrid adds a Nichols grid to the plot. The resulting Nichols-plot isnot shown in this text. However, you will see that the interesting detailsaround the critical point (gain=1=0dB, and phase=- 180 degrees) do not appearclearly. Try &quot;zoom on&quot; (executed at the command line) to see thedetails! </P>      <hr><H3><A NAME="c35"></A>3.5 Pade-approximation</H3><P>Pade-approximations are rational transfer functions which approximates thetransfer function of a time-delay. Pade-approximations can be calculated with&quot;pade&quot;. Let us as an example develop a 5'th order approximation to atime-delay of 2 seconds (or time-units), and represent it as an LTI-model (or-object):</P><TABLE BORDER="1" CELLSPACING="1" BORDERCOLOR="#000000" CELLPADDING="4" WIDTH="633"><TR><TD VALIGN="TOP"> <P><FONT SIZE="3">Tdelay=2; N=5; <BR>[numpade,denpade]=pade(Tdelay,N); <BR>tfpade=tf(numpade,denpade)</FONT></P></TD></TR></TABLE><P>MATLAB's response is</P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -