Control System Toolbox For Use with MATLAB ® Computation Visualization Programming Using the Control System Toolbox Version 1
How to Contact The MathWorks: 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Mail http://www.mathworks.com Web Anonymous FTP server Newsgroup ftp.mathworks.com comp.soft-sys.matlab support@mathworks.com suggest@mathworks.com bugs@mathworks.com doc@mathworks.com subscribe@mathworks.com service@mathworks.com info@mathworks.
Contents Introduction 1 LTI Models 2 LTI Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using LTI Models in the Control System Toolbox . . . . . . . . . . . LTI Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Precedence Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing LTI Systems As Matrices . . . . . . . . . . . . . . . . . . . . . . . Command Summary . . . . . . . . . . . . . . .
Time Delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Input/Output Delays . . . . . . . . . . . . . . . . . . . . . . . . Specifying Delays on the Inputs or Outputs . . . . . . . . . . . . . . . Specifying Delays in Discrete-Time Models . . . . . . . . . . . . . . . Retrieving Information About Delays . . . . . . . . . . . . . . . . . . . .
Tustin with Frequency Prewarping . . . . . . . . . . . . . . . . . . . . . 3-23 Matched Poles and Zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23 Discretization of Systems with Delays . . . . . . . . . . . . . . . . . . . 3-23 Resampling of Discrete-Time Models . . . . . . . . . . . . . . . . . . . 3-26 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27 Model Analysis Tools 4 General Model Characteristics . . . . . . . . . . . . . . .
Building LTI Arrays Using for Loops . . . . . . . . . . . . . . . . . . . . 5-12 Building LTI Arrays Using the stack Function . . . . . . . . . . . . 5-15 Building LTI Arrays Using tf, zpk, ss, and frd . . . . . . . . . . . . . 5-17 Indexing Into LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Particular Models in an LTI Array . . . . . . . . . . . . . Extracting LTI Arrays of Subsystems . . . . . . . . . . . . . . . . . . . Reassigning Parts of an LTI Array . . . . . . . . .
Style Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 Characteristics Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 Parameters Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5 Opening the SISO Tool Preferences Editor . . . . . . . . . . . . . . . . 8-6 Units Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7 Style Page . . . . . . . . . . . . . . . . . . .
Design Case Studies 10 Yaw Damper for a 747 Jet Transport . . . . . . . . . . . . . . . . . . . 10-3 Open-Loop Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-9 Washout Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14 Hard-Disk Read/Write Head Controller . . . . . . . . . . . . . . . 10-20 LQG Regulation: Rolling Mill Example . . . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18 GUI Reference 12 SISO Design Tool Reference 13 Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4 Import . . . . . . . . . . . . . . . . . . . . . . . . .
Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Retrieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LTI Viewer Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4 New Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5 Import Using the LTI Browser . . . . . . . . . . . . . . . . . . . . . . . . . 14-5 Export Using the LTI Viewer Export Window . . . . . . . . . . . . . 14-6 Toolbox Preferences . . . . . . . . . . . . . . . . . . . . . . .
Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4 15-5 15-6 15-6 Right-Click Menus for MIMO and LTI Arrays . . . . . . . . . . . 15-8 Axis Grouping . . . . . . . . . . . .
dsort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-65 dss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-66 dssdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-68 esort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-69 estim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
nichols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . norm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . nyquist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . obsv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . obsvf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ord2 . . . . . . . . . . . . . . . . . . . .
Index xiii
xiv Contents
1 Introduction
1 Introduction For convenience, this document gathers together nearly all the online doc for the Control System Toolbox in PDF format for printing. This document does not include Getting Started with the Control System Toolbox, which is available in both printed and PDF format.
2 LTI Models Creating LTI Models . . . . . . . . . . . . . . . . 2-8 LTI Properties . . . . . . . . . . . . . . . . . . . 2-25 Model Conversion . . . . . . . . . . . . . . . . . 2-40 Time Delays . . . . . . . . . . . . . . . . . . . . 2-43 Simulink Block for LTI Systems . . . . . . . . . . . 2-54 References . . . . . . . . . . . . . . . . . . . . .
2 LTI Models The Control System Toolbox offers extensive tools to manipulate and analyze linear time-invariant (LTI) models. It supports both continuous- and discrete-time systems. Systems can be single-input/single-output (SISO) or multiple-input/multiple-output (MIMO). In addition, you can store several LTI models in an array under a single variable name. See Chapter 4, “Arrays of LTI Models” for information on LTI arrays.
Using LTI Models in the Control System Toolbox You can manipulate TF, SS, and ZPK models using the arithmetic and model interconnection operations described in Chapter 3, “Operations on LTI Models” and analyze them using the model analysis functions, such as bode and step. FRD models can be manipulated and analyzed in much the same way you analyze the other model types, but analysis is restricted to frequency-domain methods.
2 LTI Models Creating an LTI Object: An Example An LTI object of the type TF, ZPK, SS, or FRD is created whenever you invoke the corresponding constructor function, tf, zpk, ss, or frd. For example, P = tf([1 2],[1 1 10]) creates a TF object, P, that stores the numerator and denominator coefficients of the transfer function s+2 P ( s ) = --------------------------s 2 + s + 10 See “Creating LTI Models” on page 2-8 for methods for creating all of the LTI object types.
Precedence Rules Operations like addition and commands like feedback operate on more than one LTI model at a time. If these LTI models are represented as LTI objects of different types (for example, the first operand is TF and the second operand is SS), it is not obvious what type (for example, TF or SS) the resulting model should be. Such type conflicts are resolved by precedence rules. Specifically, TF, ZPK, SS, and FRD objects are ranked according to the precedence hierarchy.
2 LTI Models sys = sys1 + sys2 because parallel connection amounts to adding the transfer matrices. Similarly, subsystems of a given LTI model sys can be extracted using matrix-like subscripting. For instance, sys(3,1:2) provides the I/O relation between the first two inputs (column indices) and the third output (row index), which is consistent with y1 y2 y3 H ( 1, 1 ) H ( 2, 1 ) = H ( 2, 1 ) H ( 2, 2 ) u 1 u 2 H ( 3, 1 ) H ( 3, 2 ) for y = Hu.
Table 2-1: Creating LTI Models (Continued) Command Description ssdata, dssdata Retrieve state-space data (respectively, descriptor state-space data). tf Create a transfer function. tfdata Retrieve transfer function data. zpk Create a zero-pole-gain model. zpkdata Retrieve zero-pole-gain data. Table 2-2: Converting LTI Models Command Description c2d Continuous- to discrete-time conversion. d2c Discrete- to continuous-time conversion. d2d Resampling of discrete-time models.
2 LTI Models Creating LTI Models The functions tf, zpk, ss, and frd create transfer function models, zero-pole-gain models, state-space models, and frequency response data models, respectively. These functions take the model data as input and produce TF, ZPK, SS, or FRD objects that store this data in a single MATLAB variable. This section shows how to create continuous or discrete, SISO or MIMO LTI models with tf, zpk, ss, and frd.
Creating LTI Models where num and den are row vectors listing the coefficients of the polynomials n ( s ) and d ( s ), respectively, when these polynomials are ordered in descending powers of s. The resulting variable h is a TF object containing the numerator and denominator data.
2 LTI Models MIMO Transfer Function Models MIMO transfer functions are two-dimensional arrays of elementary SISO transfer functions. There are several ways to specify MIMO transfer function models, including: • Concatenation of SISO transfer function models • Using tf with cell array arguments Consider the rational transfer matrix s–1 -----------s+1 . H(s ) = s+2 ---------------------------2 s + 4s + 5 You can specify H ( s ) by concatenation of its SISO entries.
Creating LTI Models N(s) = s – 1 s+2 D( s) = s+1 s2 + 4s + 5 You can specify this MIMO transfer matrix H ( s ) by typing N = {[1 –1];[1 2]}; % cell array for N(s) D = {[1 1];[1 4 5]}; % cell array for D(s) H = tf(N,D) MATLAB responds with Transfer function from input to output... s – 1 #1: ----s + 1 #2: s + 2 ------------s^2 + 4 s + 5 Notice that both N and D have the same dimensions as H.
2 LTI Models Zero-Pole-Gain Models This section explains how to specify continuous-time SISO and MIMO zero-pole-gain models. The specification for discrete-time zero-pole-gain models is a simple extension of the continuous-time case. See “Discrete-Time Models” on page 2-19. SISO Zero-Pole-Gain Models Continuous-time SISO zero-pole-gain models are of the form ( s – z 1 ) ... ( s – z m ) h ( s ) = k ------------------------------------------------( s – p 1 ) ...
Creating LTI Models 1 Defining the variable s as a ZPK model s = zpk('s') 2 Entering the transfer function as a rational expression in s. For example, once s is defined with zpk, H = –2s/((s – 2)*(s^2 + 2*s + 2)); returns the same ZPK model as h = zpk([0], [2 –1–i –1+i ], –2); Note You need only define the ZPK variable s once. All subsequent rational expressions of s will be ZPK models, unless you convert the variable s to TF.
2 LTI Models K = [–1 3;2 0]; H = zpk(Z,P,K) creates the two-input/two-output zero-pole-gain model H(s ) = –1 -----s 3(s + 5) -------------------2 (s + 1) 2 ( s 2 – 2s + 2 ) --------------------------------------------------( s – 1 ) ( s – 2 )( s – 3 ) 0 Notice that you use [] as a place-holder in Z (or P) when the corresponding entry of H ( s ) has no zeros (or poles). State-Space Models State-space models rely on linear differential or difference equations to describe the system dynamics.
Creating LTI Models As an illustration, consider the following simple model of an electric motor. dθ d2θ ---------- + 2 ------ + 5θ = 3I dt dt 2 where θ is the angular displacement of the rotor and I the driving current.
2 LTI Models In addition to the A, B, C, and D matrices, the display of state-space models includes state names, input names, and output names. Default names (here, x1, x2, u1, and y1) are displayed whenever you leave these unspecified. See “LTI Properties” on page 2-25 for more information on how to specify state, input, or output names. Descriptor State-Space Models Descriptor state-space (DSS) models are a generalization of the standard state-space models discussed above.
Creating LTI Models Frequency Response Data (FRD) Models In some instances, you may only have sampled frequency response data, rather than a transfer function or state-space model for the system you want to analyze or control. For information on frequency response analysis of linear systems, see Chapter 8 of [1]. For example, suppose the frequency response function for the SISO system you want to model is G(w).
2 LTI Models • response is a vector of length Nf of complex frequency response values for these frequencies. • units is an optional string for the units of frequency: either 'rad/s' (default) or 'Hz' For example, the MAT-file LTIexamples.mat contains a frequency vector freq, and a corresponding complex frequency response data vector respG.
Creating LTI Models Table 2-3: Data Format for the Argument response in FRD Models (Continued) Model Form Response Data Format MIMO model with Ny outputs and Nu inputs Ny-by-Nu-by-Nf multidimensional array for which response(i,j,k) specifies the frequency response from input j to output i at frequency frequency(k) S1-by-...-by-Sn array of models with Ny outputs and Nu inputs Ny-by-Nu-by-S1-by-...
2 LTI Models By convention, the sample time of continuous-time models is Ts = 0. Setting Ts = –1 leaves the sample time of a discrete-time model unspecified. For example, h = tf([1 –0.2],[1 0.3],–1) produces Transfer function: z – 0.2 ------z + 0.3 Sampling time: unspecified Note Do not simply omit Ts in this case. This would make h a continuous-time transfer function.
Creating LTI Models creates the same TF model as H = tf([1 2], [1 0.6 0.9], 0.1); Similarly, z = zpk('z', 0.1); H = [z/(z+0.1)/(z+0.2) ; (z^2+0.2*z+0.1)/(z^2+0.2*z+0.01)] produces the single-input, two-output ZPK model Zero/pole/gain from input to output... z #1: --------------(z+0.1) (z+0.2) #2: (z^2 + 0.2z + 0.1) -----------------(z+0.1)^2 Sampling time: 0.1 Note that: • The syntax z = tf('z') is equivalent to z = tf('z',–1) and leaves the sample time unspecified. The same applies to z = zpk('z').
2 LTI Models clashes with the “descending powers of z ” convention assumed by tf (see “Transfer Function Models” on page 2-8, or tf). For example, h = tf([1 0.5],[1 2 3]) produces the transfer function z + 0.5 --------------------------z 2 + 2z + 3 which differs from H ( z – 1 ) by a factor z . To avoid such convention clashes, the Control System Toolbox offers a separate function filt dedicated to the DSP-like specification of transfer functions.
Creating LTI Models Data Retrieval The functions tf, zpk, ss, and frd pack the model data and sample time in a single LTI object. Conversely, the following commands provide convenient data retrieval for any type of TF, SS, or ZPK model sys, or FRD model sysfr.
2 LTI Models 1 2 10 Note that the same result is obtained using H.num{1,1}, H.den{1,1} See “Direct Property Referencing” on page 2-31 for more information about this syntax.
LTI Properties LTI Properties The previous section shows how to create LTI objects that encapsulate the model data and sample time. You also have the option to attribute additional information, such as the input names or notes on the model history, to LTI objects. This section gives a complete overview of the LTI properties, i.e., the various pieces of information that can be attached to the TF, ZPK, SS, and FRD objects. Type help ltiprops for online help on available LTI properties.
2 LTI Models The sample time property Ts keeps track of the sample time (in seconds) of discrete-time systems. By convention, Ts is 0 (zero) for continuous-time systems, and Ts is –1 for discrete-time systems with unspecified sample time. Ts is always a scalar, even for MIMO systems. The InputDelay, OutputDelay, and ioDelay properties allow you to specify time delays in the input or output channels, or for each input/output pair. Their default value is zero (no delay).
LTI Properties following four tables. The property values differ for LTI arrays. See set for more information on these values.
2 LTI Models Table 2-8: FRD-Specific Properties Property Name Description Property Value Frequency Frequency data points Real-valued vector ResponseData Frequency response Complex-valued multidimensional array Units Units for frequency String 'rad/s' or 'Hz' Most of these properties are dedicated to storing the model data. Note that the E matrix is set to [] (the empty matrix) for standard state-space models, a storage-efficient shorthand for the true value E = I .
LTI Properties The function set for LTI objects follows the same syntax as its Handle Graphics counterpart. Specifically, each property is updated by a pair of arguments PropertyName,PropertyValue where • PropertyName is a string specifying the property name. You can type the property name without regard for the case (upper or lower) of the letters in the name. Actually, you need only type any abbreviation of the property name that uniquely identifies the property.
2 LTI Models Finally, you can also use the set command to obtain a listing of all settable properties for a given LTI model type, along with valid values for these properties. For the transfer function sys created above set(sys) produces num: Ny-by-Nu cell of row vectors (Nu = no. of inputs) den: Ny-by-Nu cell of row vectors (Ny = no.
LTI Properties To display all of the properties of an LTI model sys (and their values), use the syntax get(sys). In this example, get(h) produces num = {[0 0 100]} den = {[1 5 100]} Variable = 's' Ts = 0 InputDelay = 0 OutputDelay = 0 ioDelay = 0 InputName = {'voltage'} OutputName = {'current'} InputGroup = {0x2 cell} OutputGroup = {0x2 cell} Notes = {'A simple circuit'} UserData = [] Notice that default (output) values have been assigned to any LTI properties in this list that you have not specified.
2 LTI Models sys = ss(1,2,3,4,'InputName','u'); sys.a and you get the value of the property “a” for the state-space model sys. ans = 1 Similarly, sys.a = –1; resets the state transition matrix for sys to –1. Unlike standard MATLAB structures, you do not need to type the entire field name or use upper-case characters. You only need to type the minimum number of characters sufficient to identify the property name uniquely. Thus either of the commands sys.InputName sys.
LTI Properties Properties” on page 2-25. For detailed information on the use of InputDelay, OutputDelay, and ioDelay, see “Time Delays” on page 2-43. Sample Time The sample time property Ts is used to specify the sampling period (in seconds) for either discrete-time or discretized continuous-time LTI models. Suppose you want to specify z H ( z ) = ---------------------------2 2z + z + 1 as a discrete-time transfer function model with a sampling period of 0.5 seconds.
2 LTI Models Sampling time: unspecified The same result is obtained by using the Variable property. h = tf(1,[1 –1],'var','z') In operations that combine several discrete-time models, all specified sample times must be identical, and the resulting discrete-time model inherits this common sample time. The sample time of the resultant model is unspecified if all operands have unspecified sample times. With this inheritance rule for Ts, the following two models are equivalent. tf(0.1,[1 –1],0.
LTI Properties Input Names and Output Names You can use the InputName and OutputName properties (in short, I/O names) to assign names to any or all of the input and output channels in your LTI model. For example, you can create a SISO model with input thrust, output velocity, and transfer function H ( p ) = 1 ⁄ ( p + 10 ) by typing h = tf(1,[1 10]); set(h,'inputname','thrust','outputname','velocity',...
2 LTI Models s + 2 ----s To leave certain names undefined, use the empty string '' as in H = tf(num,den,'inputname',{ 'temperature' ; '' }) Input Groups and Output Groups In many applications, you may want to create several (distinct or intersecting) groups of input or output channels and name these groups. For example, you may want to label one set of input channels as noise and another set as controls.
LTI Properties c = y1 y2 y3 x1 1.1909 1.1892 0 y1 y2 y3 u1 0.32729 0 0 d = I/O Groups: Group Name controls temperature measurements I/O I O O u2 0 0 2.1832 u3 –0.1364 0 0 Channel(s) 1,2 1 2,3 Continuous-time model. Notice that the middle column of the I/O group listing indicates whether the group is an input group (I) or an output group (O).
2 LTI Models In general, to specify M input groups (or output groups), you need an M-by-2 cell array organized as follows. Group Names Vectors of Channel Indices { Channels for Group 1 , Name for Group 1; Channels for Group 2 , Name for Group 2; Channels for Group M , Name for Group M } Figure 2-2: Two Column Cell Array When you specify the cell array for input (or output) groups, keep in mind: • Each row of this cell array designates a different input (output) group.
LTI Properties Similarly, you can add or delete channels from an existing input or output group. Recalling that input group channels are stored in the first column of the corresponding cell array, to add channel three to the input group controls, type h.inputgroup{1,1} = [h.inputgroup{1,1} 3] or, equivalently, h.
2 LTI Models Model Conversion There are four LTI model types you can use with the Control System Toolbox: TF, ZPK, SS, and FRD. This section shows how to convert models from one type to the other. Explicit Conversion Model conversions are performed by tf, ss, zpk, and frd.
Model Conversion –1 H ( z ) = D + C ( zI – A ) B for discrete-time models. Automatic Conversion Some algorithms operate only on one type of LTI model. For example, the algorithm for zero-order-hold discretization with c2d can only be performed on state-space models. Similarly, commands like tfdata expect one particular type of LTI models (TF). For convenience, such commands automatically convert LTI models to the appropriate or required model type.
2 LTI Models ss(tf(sys)) may return a model with different state-space matrices, or even a different number of states in the MIMO case. Therefore, if possible, it is best to avoid converting back and forth between state-space and other model types.
Time Delays Time Delays Using the ioDelay, InputDelay, and OutputDelay properties of LTI objects, you can specify delays in both continuous- and discrete-time LTI models. With these properties, you can, for example, represent: • LTI models with independent delays for each input/output pair. For example, the continuous-time model with transfer function H( s) = e – 0.1s 10 2 --s e e – 0.3s – 0.
2 LTI Models • Interconnections of continuous-time delay systems as long as the resulting transfer function from input j to output i is of the form exp ( – sτ ij ) h ij ( s ) where h ij ( s ) is a rational function of s • Padé approximation of time delays (pade) Specifying Input/Output Delays Using the ioDelay property, you can specify frequency-domain models with independent delays in each entry of the transfer function.
Time Delays This creates the LTI model with the following transfer function. H( s) = exp ( – sτ ij ) r ij ( s ) Here r ij ( s ) is the ( i, j ) entry of –1 R ( s ) = D + C ( sI – A ) B Note State-space models with I/O delays have only a frequency-domain interpretation. They cannot, in general, be described by state-space equations with delayed inputs and outputs. Distillation Column Example This example is adapted from [2] and illustrates the use of I/O delays in process modeling.
2 LTI Models Enriched vapor Cooling water Condensate Distillate Feed Reflux Reboiler Vapor Steam flow Bottom liquid Bottom products Figure 2-3: Distillation Column Schematically, the distillation process functions as follows: • Steam flows into the reboiler and vaporizes the bottom liquid. This vapor is reinjected into the column and mixes with the feed • Methanol, being more volatile than water, tends to concentrate in the vapor moving upward.
Time Delays The goal is to maximize X D by adjusting the reflux flow rate R and the steam flow rate S in the reboiler. To obtain a linearized model around the steady-state operating conditions, the transient responses to pulses in steam and reflux flow are fitted by first-order plus delay models. The resulting transfer function model is – 1s XD( s ) XB ( s ) = – 3s 12.8e – 18.9e ------------------------ ------------------------16.7e + 1 21.0s + 1 R ( s ) – 7s – 3s S ( s ) – 19.4e 6.
2 LTI Models Specifying Delays on the Inputs or Outputs While ideal for frequency-domain models with I/O delays, the ioDelay property is inadequate to capture delayed inputs or outputs in state-space models. For example, the two models · ( M 1 ) x ( t ) = – x ( t ) + u ( t – 0.1 ) è y(t) = x(t) · ( M2 ) z ( t ) = –z ( t ) + u ( t ) è y ( t ) = z ( t – 0.1 ) share the same transfer function – 0.
Time Delays x· ( t ) = Ax ( t ) + B 1 u 1 ( t – 0.1 ) + B 2 u 2 ( t ) y 1 ( t + 0.2 ) = C 1 x ( t ) + D 11 u 1 ( t – 0.1 ) + D 12 u 2 ( t ) y 2 ( t + 0.3 ) = C 2 x ( t ) + D 21 u 1 ( t – 0.1 ) + D 22 u 2 ( t ) You can also use the InputDelay and OutputDelay properties to conveniently specify input or output delays in TF, ZPK, or FRD models. For example, you can create the transfer function 1 --s H( s) = 2 -----------s+1 e – 0.1s by typing s = tf('s'); H = [1/s ; 2/(s+1)]; H.inputdelay = 0.
2 LTI Models α1 + β1 α2 + β1 α1 + β2 α2 + β2 : α1 + βp : α2 + βp ... α m + β1 α m + β2 ... : αm + βp Specifying Delays in Discrete-Time Models You can also use the ioDelay, InputDelay, and OutputDelay properties to specify delays in discrete-time LTI models. You specify time delays in discrete-time models with integer multiples of the sampling period. The integer k you supply for the time delay of a discrete-time model specifies a time delay –k of k sampling periods.
Time Delays –2 z H ( z ) = -----------z–1 You can specify this model either as the first-order transfer function 1 ⁄ ( z – 1 ) with a delay of two sampling periods on the input Ts = 1; % sampling period H1 = tf(1,[1 –1],Ts,'inputdelay',2) or directly as a third-order transfer function: H2 = tf(1,[1 –1 0 0],Ts) % 1/(z^3–z^2) While these two models are mathematically equivalent, H1 is a more efficient representation both in terms of storage and subsequent computations.
2 LTI Models sys.iodelay get(sys,'inputdelay') • Use the helper function hasdelay to determine if sys has any delay at all. The syntax is hasdelay(sys) which returns 1 (true) if sys has any delay, and 0 (false) otherwise • Use the function totaldelay to determine the total delay between each input and each output (cumulative contribution of the ioDelay, InputDelay, and OutputDelay properties). Type help totaldelay or see the Reference pages for details.
Time Delays To compute a Padé approximation of H(s) using: • A first-order approximation for the 1 second and 3 second delays • A second-order approximation for the 7 second delay, type pade(H,[],[],[1 1;2 1]) where H is the TF representation of H ( s ) defined in the distillation column example. This command produces a rational transfer function. Transfer function from input "R" to output... –12.8 s + 25.6 Xd: --------------------16.7 s^2 + 34.4 s + 2 Xb: 6.6 s^2 – 5.657 s + 1.
2 LTI Models Simulink Block for LTI Systems You can incorporate LTI objects into Simulink diagrams using the LTI System block shown below. This mask is linked to an LTI block in a Simulink diagram. Double-click on the block in your Simulink diagram to display or modify model information. The LTI System block can be accessed either by typing ltiblock at the MATLAB prompt or by selecting Control System Toolbox from the Blocksets and Toolboxes section of the main Simulink library.
Simulink Block for LTI Systems transfer functions or zero-pole-gain models, as it depends on the choice of state coordinates used by the realization algorithm. As a result, you cannot enter nonzero initial states when you supply TF or ZPK models to LTI blocks in a Simulink diagram. Note: • For MIMO systems, the input delays stored in the LTI object must be either all positive or all zero. • LTI blocks in a Simulink diagram cannot be used for FRD models or LTI arrays.
2 LTI Models References [1] Dorf, R.C. and R.H. Bishop, Modern Control Systems, Addison-Wesley, Menlo Park, CA, 1998. [2] Wood, R.K. and M.W. Berry, “Terminal Composition Control of a Binary Distillation Column,” Chemical Engineering Science, 28 (1973), pp. 1707-1717.
3 Operations on LTI Models Precedence and Property Inheritance . . . . . . . . 3-3 Extracting and Modifying Subsystems . . Referencing FRD Models Through Frequencies Referencing Channels by Name . . . . . . . Resizing LTI Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arithmetic Operations . . . Addition and Subtraction . . . Multiplication . . . . . . . . Inversion and Related Operations Transposition . . . . . . . . Pertransposition . . . . . . . . . . . . . . . . .
3 Operations on LTI Models You can perform basic matrix operations such as addition, multiplication, or concatenation on LTI models. Such operations are “overloaded,” which means that they use the same syntax as they do for matrices, but are adapted so as to apply to the LTI model context. These overloaded operations and their interpretation in this context are discussed in this chapter. You can read about discretization methods in this chapter as well.
Precedence and Property Inheritance Precedence and Property Inheritance You can apply operations to LTI models of different types. The resulting type is then determined by the rules discussed in “Precedence Rules” on page 2-5. For example, if sys1 is a transfer function and sys2 is a state-space model, then the result of their addition sys = sys1 + sys2 is a state-space model, since state-space models have precedence over transfer function models.
3 Operations on LTI Models • In general, when two LTI models sys1 and sys2 are combined using operations such as +, *, [,], [;], append, and feedback, the resulting model inherits its I/O names and I/O groups from sys1 and sys2. However, conflicting I/O names or I/O groups are not inherited. For example, the InputName property for sys1 + sys2 is left unspecified if sys1 and sys2 have different InputName property values.
Extracting and Modifying Subsystems Extracting and Modifying Subsystems Subsystems relate subsets of the inputs and outputs of a system. The transfer matrix of a subsystem is a submatrix of the system transfer matrix. For example, if sys is a system with two inputs, three outputs, and I/O relation y = Hu then H ( 3, 1 ) gives the relation between the first input and third output. y 3 = H ( 3,1 ) u 1 Accordingly, use matrix-like subindexing to extract this subsystem.
3 Operations on LTI Models The following rules apply when modifying LTI models: • sys, the LTI model that has had a portion reassigned, retains its original model type (TF, ZPK, SS, or FRD) regardless of the model type of NewSubSys. • Subsystem assignment does not reassign any I/O names or I/O group names of NewSubSys that are already assigned to NewSubSys. • Reassigning parts of a MIMO state-space model generally increases its order. • If NewSubSys is an FRD model, then sys must also be an FRD model.
Extracting and Modifying Subsystems Next reassign T 11 ( s ) to 1 ⁄ ( s + 0.5 ) and modify the second input channel of T by typing T(1,1) = tf(1,[1 0.5]); T(:,2) = [ 1 ; tf(0.4,[1 0]) ] Transfer function from input 1 to output... 1 #1: ------s + 0.5 #2: s – 1 ------------s^2 + 2 s + 2 Transfer function from input 2 to output... #1: 1 #2: 0.
3 Operations on LTI Models sys2.Frequency ans = 1.1000 1.2000 displays the second and third entries in the frequency vector. Similarly, you can use logical indexing into the frequencies. sys2 = sys('frequency',sys.Frequency >1.0 & sys.Frequency <1.15); sys2.freq ans = 1.1000 You can also combine model extraction through frequencies with indexing into the I/O dimensions. For example, if sys is an FRD model with two inputs, two outputs, and frequency vector [2.1 4.2 5.3], with sys.
Extracting and Modifying Subsystems You can reference a set of channels by input or output name by using a cell array of strings for the names. For example, if sys has one output channel named pressure and one named temperature, then these two output channels can be referenced using sys({'pressure','temperature'}) Resizing LTI Systems Resizing a system consists of adding or deleting inputs and/or outputs.
3 Operations on LTI Models adds a second input to the state-space model sys by appending the B and D matrices. You should simultaneously modify both matrices with a single set command. Indeed, the statements sys.b = [b1 b2] and set(sys,'b',[b1 b2]) cause an error because they create invalid intermediate models in which the B and D matrices have inconsistent column dimensions.
Arithmetic Operations Arithmetic Operations You can apply almost all arithmetic operations to LTI models, including those shown below. Operation Description + Addition – Subtraction * Multiplication / Right matrix divide \ Left matrix divide inv Matrix inversion ' Pertransposition .' Transposition ^ Powers of an LTI model (as in s^2) Addition and Subtraction Adding LTI models is equivalent to connecting them in parallel.
3 Operations on LTI Models represents the parallel interconnection shown below. sys1 y1 + u y + sys2 y2 sys If sys1 and sys2 are two state-space models with data A 1, B 1, C 1, D 1 and A 2, B 2, C 2, D 2 , the state-space data associated with sys1 + sys2 is A1 0 0 A2 , B1 , C1 C2 , B2 D1 + D2 Scalar addition is also supported and behaves as follows: if sys1 is MIMO and sys2 is SISO, sys1 + sys2 produces a system with the same dimensions as sys1 whose ijth entry is sys1(i,j) + sys2.
Arithmetic Operations Multiplication Multiplication of two LTI models connects them in series. Specifically, sys = sys1 * sys2 returns an LTI model sys for the series interconnection shown below. v u sys2 sys1 y Notice the reverse orders of sys1 and sys2 in the multiplication and block diagram.
3 Operations on LTI Models • Left division sys1\sys2, which is equivalent to inv(sys1)*sys2 • Right division sys1/sys2, which is equivalent to sys1*inv(sys2) For a state-space model sys with data A, B, C, D , inv(sys) is defined only when D is a square invertible matrix, in which case its state-space data is –1 A – BD C , BD –1 , –1 –D C , D –1 Transposition You can transpose an LTI model sys using sys.
Arithmetic Operations pertranspose of H ( s ), G ( s ) = [ H ( – s ) ] T , is the Hermitian transpose of the frequency response of H ( s ): G ( jw ) = H ( jw ) H .
3 Operations on LTI Models Model Interconnection Functions The Control System Toolbox provides a number of functions to help with the model building process. These include model interconnection functions to perform I/O concatenation ([,], [;], and append), general parallel and series connections (parallel and series), and feedback connections (feedback and lft). These functions are useful to model open- and closed-loop systems.
Model Interconnection Functions sys = append(sys1,sys2)% block diagonal appending In I/O terms, horizontal and vertical concatenation have the following block-diagram interpretations (with H 1 and H 2 denoting the transfer matrices of sys1 and sys2). H1 u1 H1 y1 H2 y2 + + u2 y u H2 y = H1 , H 2 u1 y1 u2 y2 Horizontal Concatenation = H1 u H2 Vertical Concatenation You can use concatenation as an easy way to create MIMO transfer functions or zero-pole-gain models.
3 Operations on LTI Models to specify the block-decoupled LTI model interconnection. u1 y1 sys1 sys1 0 0 sys2 u2 sys2 y2 Transfer Function Appended Models See append for more information on this function. Feedback and Other Interconnection Functions The following LTI model interconnection functions are useful for specifying closed- and open-loop model configurations: • feedback puts two LTI models with compatible dimensions in a feedback configuration.
Model Interconnection Functions is realized with feedback(sys1,sys2) This specifies the LTI model with m inputs and p outputs whose I/O map is ( I + sys1 ⋅ sys2 ) –1 sys1 See the reference pages online for more information on feedback, series, parallel, lft, and connect.
3 Operations on LTI Models Continuous/Discrete Conversions of LTI Models The function c2d discretizes continuous-time TF, SS, or ZPK models. Conversely, d2c converts discrete-time TF, SS, or ZPK models to continuous time. Several discretization/interpolation methods are supported, including zero-order hold (ZOH), first-order hold (FOH), Tustin approximation with or without frequency prewarping, and matched poles and zeros.
Continuous/Discrete Conversions of LTI Models The signal u ( t ) is then fed to the continuous system H ( s ) , and the resulting output y ( t ) is sampled every T s seconds to produce y [ k ] . Conversely, given a discrete system H d ( z ) , the d2c conversion produces a continuous system H ( s ) whose ZOH discretization coincides with H d ( z ) . This inverse operation has the following limitations: • d2c cannot operate on LTI models with poles at z = 0 when the ZOH is used.
3 Operations on LTI Models --------(z+0.5)^2 Sampling time: 0.1 First-Order Hold First-order hold (FOH) differs from ZOH by the underlying hold mechanism. To turn the input samples u [ k ] into a continuous input u ( t ) , FOH uses linear interpolation between samples. t – kT s u ( t ) = u [ k ] + ------------------ ( u [ k + 1 ] – u [ k ] ) , Ts kTs ≤ t ≤ ( k + 1 )T s This method is generally more accurate than ZOH for systems driven by smooth inputs.
Continuous/Discrete Conversions of LTI Models H ( s ) = H d ( z' ), where 1 + sT s ⁄ 2 z' = -------------------------1 – sT s ⁄ 2 Tustin with Frequency Prewarping This variation of the Tustin approximation uses the correspondence z–1 ω s' = --------------------------------- -----------tan ( ωT s ⁄ 2 ) z + 1 H d ( z ) = H ( s' ) , This change of variable ensures the matching of the continuous- and discrete-time frequency responses at the frequency ω .
3 Operations on LTI Models using zero-order hold on the input, and a 10 Hz sampling rate, type h = tf(10,[1 3 10],'inputdelay',0.25); hd = c2d(h,0.1) This produces the discrete-time transfer function Transfer function: 0.01187 z^2 + 0.06408 z + 0.009721 z^(–2) * ---------------------------------z^3 – 1.655 z^2 + 0.7408 z Sampling time: 0.1 Here the input delay in H ( s ) amounts to 2.5 times the sampling period of 0.1 seconds.
Continuous/Discrete Conversions of LTI Models step(h,'--',hd,'-') Step Response 1.4 1.2 Amplitude 1 0.8 0.6 0.4 0.2 0 0 0.5 1 1.5 2 2.5 3 3.5 4 Time (sec.) Note The Tustin and matched pole/zero methods are accurate only for delays that are integer multiples of the sampling period. It is therefore preferable to use the zoh and foh discretization methods for models with delays.
3 Operations on LTI Models Resampling of Discrete-Time Models You can resample a discrete-time TF, SS, or ZPK model sys1 by typing sys2 = d2d(sys1,Ts) The new sampling period Ts does not have to be an integer multiple of the original sampling period. For example, typing h1 = tf([1 0.4],[1 –0.7],0.1); h2 = d2d(h1,0.25); resamples h1 at the sampling period of 0.25 seconds, rather than 0.1 seconds.
References References [1] Åström, K.J. and B. Wittenmark, Computer-Controlled Systems: Theory and Design, Prentice-Hall, 1990, pp. 48–52. [2] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of Dynamic Systems, Second Edition, Addison-Wesley, 1990.
3 Operations on LTI Models 3-28
4 Model Analysis Tools General Model Characteristics . . . . . . . . . . . 4-2 Model Dynamics . . . . . . . . . . . . . . . . . . 4-4 State-Space Realizations . . . . . . . . . . . . . .
4 Model Analysis Tools 4-2
General Model Characteristics General Model Characteristics General model characteristics include the model type, I/O dimensions, and continuous or discrete nature. Related commands are listed in the table below. These commands operate on continuous- or discrete-time LTI models or arrays of LTI models of any type. General Model Characteristics Commands class Display model type ('tf', 'zpk', 'ss', or 'frd'). hasdelay Test true if LTI model has any type of delay.
4 Model Analysis Tools Transfer function from input 2 to output: s – 1 -------------s^2 + 2 s + 10 class(H) ans = tf size(H) Transfer function with 2 input(s) and 1 output(s).
Model Dynamics Model Dynamics The Control System Toolbox offers commands to determine the system poles, zeros, DC gain, norms, etc. You can apply these commands to single LTI models or LTI arrays. The following table gives an overview of these commands. Model Dynamics covar Covariance of response to white noise. damp Natural frequency and damping of system poles. dcgain Low-frequency (DC) gain. dsort Sort discrete-time poles by magnitude. esort Sort continuous-time poles by real part.
4 Model Analysis Tools –1.7971 – 2.2137i –0.2629 + 2.7039i –0.2629 – 2.7039i zero(h) ans = –0.0500 + 2.7382i –0.0500 – 2.7382i –2.0000 dcgain(h) ans = 1 [ninf,fpeak] = norm(h,inf)% peak gain of freq. response ninf = 1.3402 % peak gain fpeak = 1.8537 % frequency where gain peaks These functions also operate on LTI arrays and return arrays. For example, the poles of a three dimensional LTI array sysarray are obtained as follows.
Model Dynamics Model sysarray(:,:,3,1) ======================= Transfer function: 0.621 s + 0.7567 --------------------s^2 + 2.942 s + 2.113 3x1 array of continuous-time transfer functions. pole(sysarray) ans(:,:,1) = -3.6337 -2.0379 ans(:,:,2) = -0.8549 -0.2011 ans(:,:,3) = -1.6968 -1.
4 Model Analysis Tools State-Space Realizations The following functions are useful to analyze, perform state coordinate transformations on, and derive canonical state-space realizations for single state-space LTI models or LTI arrays of state-space models. State-Space Realizations canon Canonical state-space realizations. ctrb Controllability matrix. ctrbf Controllability staircase form. gram Controllability and observability gramians. obsv Observability matrix.
State-Space Realizations poorly suited for state-space computations. Consequently, it is wise to use them only for analysis purposes and not in control design algorithms.
4 Model Analysis Tools 4-10
5 Arrays of LTI Models Introduction . . . . . . . . . . . . . . . When to Collect a Set of Models in an LTI Array . Restrictions for LTI Models Collected in an Array Where to Find Information on LTI Arrays . . . . . . . . . . . . . . . . . . . . . . . 5-4 5-2 5-2 5-3 The Concept of an LTI Array . . . . . . . . . . . . 5-4 Higher Dimensional Arrays of LTI Models . . . . . . . . 5-6 Dimensions, Size, and Shape of an LTI Array . . . . . 5-7 size and ndims . . . . . . . . . . . . . . . . . . . .
5 Arrays of LTI Models Introduction In many applications, it is useful to consider collections of linear, time invariant (LTI) models. For example, you may want to consider a model with a single parameter that varies, such as sys1 = tf(1, [1 1 1]); sys2 = tf(1, [1 1 2]); sys3 = tf(1, [1 1 3]); and so on. A convenient way to store and analyze a collection like this is to use LTI arrays. Continuing this example, you can create this LTI array and store all three transfer functions in one variable.
Introduction • The number of inputs and outputs • The sample time, for discrete-time models • The I/O names and I/O groups Note You cannot specify Simulink LTI blocks with LTI arrays. Where to Find Information on LTI Arrays The next two sections give examples that illustrate the concept of an LTI array, its dimensions, and size. To read about how to build an LTI array, go to “Building LTI Arrays” on page 4-12. The remainder of the chapter is devoted to indexing and operations on LTI Arrays.
5 Arrays of LTI Models The Concept of an LTI Array To visualize the concept of an LTI array, consider the set of five transfer function models shown below. In this example, each model has two inputs and two outputs. They differ by parameter variations in the individual model components. 1.1 -----------s+1 0 1.3 ----------------s + 1.1 0 1.11 ----------------s + 1.2 0 1.15 ----------------s + 1.3 0 1.09 ----------------s + 1.4 0 0 1 -----------s+5 0 1 ----------------s + 5.
The Concept of an LTI Array Just as you might collect a set of two-by-two matrices in a multidimensional array, you can collect this set of five transfer function models as a list in an LTI array under one variable name, say, sys. Each element of the LTI array is an LTI model. Individual models in the LTI array sys are accessed via indexing. The general form for the syntax you use to access data in an LTI array is sysa(Outputs,Inputs,Models) The first index selects the output channels.
5 Arrays of LTI Models Higher Dimensional Arrays of LTI Models You can also collect a set of models in a two-dimensional array. The following diagram illustrates a 2-by-3 array of six, two-output, one-input models called m2d. m2d(:,:,1,3) Each entry in this 2-by-3 array of models is a two-output, one-input transfer function. 3.42 -------------------s + 2.84 7.29 m2d(:,:,1,1) m2d(:,:,2,1) 3.36 ----------------s + 2.9 7.23 m2d(:,:,1,2) m2d(:,:,2,2) 3.4 -------------------s + 2.86 7.
Dimensions, Size, and Shape of an LTI Array Dimensions, Size, and Shape of an LTI Array The dimensions and size of a single LTI model are determined by the output and input channels. An array of LTI models has additional quantities that determine its dimensions, size, and shape.
5 Arrays of LTI Models . The next figure illustrates the concepts of dimension and size for the LTI array m2d, a 2-by-3 array of one-input, two-output transfer function models. m2d(:,:,1,1) m2d(:,:,1,2) m2d(:,:,1,3) m2d(:,:,2,1) m2d(:,:,2,2) m2d(:,:,2,3) T he le n gt h of th e fi rs t ar r ay di m ens ion is 2 The length of the second array dimension is 3. 3.4 -------------------s + 2.86 7.27 3.45 -------------------s + 2.81 7.32 m2d(:,:,2,3) Output dimension (length 2) 3.
Dimensions, Size, and Shape of an LTI Array • N, the number of models in the LTI array • K, the number of array dimensions • S 1 S 2 …S K, the list of lengths of the array dimensions - S i is the number of models along the i th dimension. • S 1 – by – S 2 – by – … – by – S K , the configuration of the models in the array - The configuration determines the shape of the array. - The product of these integers S 1 × S 2 × … × SK is N.
5 Arrays of LTI Models Note the following when using the size function: • By convention, a single LTI model is treated as a 1-by-1 array of models. For single LTI models, size returns only the I/O dimensions [Ny Nu]. • For LTI arrays, size always returns at least two array dimensions. For example, the size of a 2-by-1 LTI array in [Ny Nu 2 1] • size ignores trailing singleton dimensions beyond the second array dimension.
Dimensions, Size, and Shape of an LTI Array reshape Use reshape to reorganize the arrangement (array configuration) of the models of an existing LTI array. For example, to arrange the models in an LTI Array sys as a w 1 × … × w p array, type reshape(sys,w1,...,wp) where w1,...,wp are any set of integers whose product is N, the number of models in sys. You can reshape the LTI array m2d into a 3-by-2, a 6-by-1, or a 1-by-6 array using reshape.
5 Arrays of LTI Models Building LTI Arrays There are several ways to build LTI arrays: • Using a for loop to assign each model in the array • Using stack to concatenate LTI models into an LTI array • Using tf, zpk, ss, or frd In addition, you can use the command rss to generate LTI arrays of random state-space models. Generating LTI Arrays Using rss A convenient way to generate arrays of state-space models with the same number of states in each model is to use rss. The syntax is rss(N,P,M,sdim1,...
Building LTI Arrays Suppose, based on measured input and output data, you estimate confidence intervals [ω 1,ω 2] , and [ζ 1,ζ 2] for each of the parameters, ω and ζ. All of the possible combinations of the confidence limits for these model parameter values give rise to a set of four SISO models.
5 Arrays of LTI Models The first two colon indices ( : ) select all I/O channels from the I/O dimensions of H. The third index of H refers to the first array dimension ( ζ), while the fourth index is for the second array dimension (ω). Suppose the limits of the ranges of values for ζ and ω are [0.66,0.76] and [1.2,1.5], respectively. Enter these at the command line. zeta = [0.66,0.75]; w = [1.2,1.
Building LTI Arrays For the purposes of efficient computation, you can initialize an LTI array to zero, and then reassign the entire array to the values you want to specify. The general syntax for zero assignment of LTI arrays is Lengths of the output/input dimensions Lengths of the array dimensions sysa = tf(zeros(Ny,Nu,S1,...,SK)) sysa = zpk(zeros(Ny,Nu,S1,...,SK)) sysa = ss(zeros(Ny,Nu,S1,...,SK,Nx)) sysa = frd(zeros(Ny,Nu,Nf,S1,...
5 Arrays of LTI Models When you concatenate several models or LTI arrays along the jth array dimension, such as in stack(j,sys1,sys2,...,sysn) • The lengths of the I/O dimensions of sys1,...,sysn must all match. • The lengths of all but the jth array dimension of sys1,...,sysn must match. For example, if two TF models sys1 and sys2 have the same number of inputs and outputs, sys = stack(1,sys1,sys2) concatenates them into a 2-by-1 array of models.
Building LTI Arrays Notice that this result is very different from the single MIMO LTI model returned by H = [H11,H12;H21,H22]; Building LTI Arrays Using tf, zpk, ss, and frd You can also build LTI arrays using the tf, zpk, ss, and frd constructors. You do this by using multidimensional arrays in the input arguments for these functions.
5 Arrays of LTI Models • gains is a multidimensional array containing the scalar gains for each I/O pair of each model in the array. • The dimensions (and their lengths) of zeros, poles, and gains, determine those of the LTI array, sys. Specifying Arrays of SS Models Using ss To specify arrays of SS models, use sys = ss(a,b,c,d) where a, b, c, and d are real-valued multidimensional arrays of appropriate dimensions.
Building LTI Arrays Specifying Arrays of FRD Models Using frd To specify a K-dimensional array of p-output, m-input FRD models for which S 1, S 2, …, S K are the lengths of the array dimensions, use sys = frd(response,frequency,units) where • frequency is a real vector of n frequency data points common to all FRD models in the LTI array. • response is a p-by-m-by-n-by- S 1 -by- …-by- S K complex-valued multidimensional array. • units is the optional string specifying 'rad/s' or 'Hz'.
5 Arrays of LTI Models Indexing Into LTI Arrays You can index into LTI arrays in much the same way as you would for multidimensional arrays to: • Access models • Extract subsystems • Reassign parts of an LTI array • Delete parts of an LTI array When you index into an LTI array sys, the indices should be organized according to the following format sys(Outputs, Inputs, n 1, …, n K ) where • Outputs are indices that select output channels. • Inputs are indices that select input channels.
Indexing Into LTI Arrays • The remaining indices specify the model coordinates within the array.
5 Arrays of LTI Models or equivalently, A = sys(1,[1 2],:,:) selects the first two input channels, and the first output channel in each model of the LTI array A, and returns the resulting 5-by-2 array of one-output, two-input subsystems. You can also combine model selection with I/O selection within an LTI array.
Indexing Into LTI Arrays Notice that you don’t have to use the array dimensions with this assignment. This is because I/O selection applies to all models in the array when the array indices are omitted. Similarly, the commands sys(:,:,3,2) = sys(:,:,4,1); sys(1,2,3,2) = 0; reassign the entire model in the (3,2) position of the LTI array sys and the (1,2) subsystem of this model, respectively.
5 Arrays of LTI Models Operations on LTI Arrays Using LTI arrays, you can apply almost all of the basic model operations that work on single LTI models to entire sets of models at once. These basic operations include: • The arithmetic operations: +, –, *, /,\,',.
Operations on LTI Arrays Example: Addition of Two LTI Arrays The following diagram illustrates the addition of two 3-by-1 LTI arrays sys1+sys2. sys2(:,:,3) sys1(:,:,3 1 -----------s+2 + sys1(:,:,2) 1 ----------------s + 2.5 sys1 2s + 6.5 --------------------------------2 s + 6.5s + 9 = sys2(:,:,2) + sys1(:,:,1 1 ----------------s + 2.9 1 ---------------s + 4.5 sys(:,:,3) 2.1 -----------s+4 sys(:,:,2) = 3.15 + 9.25 -----------------------------------2 s + 6.
5 Arrays of LTI Models Note that: • Each model in sys1 and sys2 must have the same number of inputs and outputs. This is required for the addition of two LTI arrays. • The lengths of the array dimensions of sys1 and sys2 must match. Dimension Requirements In general, when you apply any of these basic operations to two or more LTI arrays: • The I/O dimensions of each of the LTI arrays must be compatible with the requirements of the operation. • The lengths of array dimensions must match.
Operations on LTI Arrays dimensions as sys1. You can use shortcuts for coding sysa = op(sys1,sys2) in the following cases: • For operations that apply to LTI arrays, sys2 does not have to be an array. It can be a single LTI model (or a gain matrix) whose I/O dimensions satisfy the compatibility requirements for op (with those of each of the models in sys1).
5 Arrays of LTI Models h(:,:,i)=tf(1,[1 tau]); end H = [h 0; –1 tf(1,[1 0])]; %Concatenation: array h & single models size(H) 3x1 array of continuous-time transfer functions Each transfer function has 2 output(s) and 2 input(s). Similarly, you can use append to perform the diagonal appending of each model in the SISO LTI array h with a fixed single (SISO or MIMO) LTI model. S = append(h,tf(1,[1 3])); % Append a single model to h.
Operations on LTI Arrays adds the array of scalars to each entry of each MIMO model in the LTI array [h,h] on a model-by-model basis. This last command is equivalent to the following for loop. hh = [h,h]; for k = 1:3 sysa(:,:,k) = G(1,1,k) + hh(:,:,k); end Other Operations on LTI Arrays You can also apply the analysis functions, such as bode, nyquist, and step, to LTI arrays.
5 Arrays of LTI Models 5-30
6 Customization The Property and Preferences Hierarchy . . . . . . . . .
6 Customization The Control System Toolbox provides editors that allow you to set properties and preferences in the SISO Design Tool, the LTI Viewer, and in any response plots that you create from the MATLAB prompt. Properties refer to settings that are specific to an individual response plot.
The Property and Preferences Hierarchy This diagram explains the hierarchy from properties, which are local, to toolbox preferences, which are global and persist from session to session.
6 Customization 6-4
7 Setting Toolbox Preferences Opening the Toolbox Preferences Editor Units Page . . . . . . . . . . . . Style Page . . . . . . . . . . . . Characteristics Page . . . . . . . . SISO Tool Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7 Setting Toolbox Preferences The Toolbox Preferences Editor allows you to set plot preferences that will persist from session to session. This is the highest level shown in “The Property and Preferences Hierarchy”. Opening the Toolbox Preferences Editor To open the Toolbox Preferences Editor, select Toolbox Preferences under the File menu of the LTI Viewer or the SISO Design Tool. Alternatively, you can type ctrlpref at the MATLAB prompt.
Units Page Note To get help on pages in the Control System Toolbox Preferences editor, click on the page tabs below. Use the Units page to set preferences for the following: • Frequency — Radians per second (rad/sec) or Hertz (Hz) • Magnitude — Decibels (dB) or absolute value (abs) • Phase — Degrees or radians For frequency and magnitude axes, you can select logarithmic or linear scales. Style Page Note Click on the page tabs below to get help on pages in the Control System Toolbox Preferences editor.
7 Setting Toolbox Preferences Use the Style page to toggle grid visibility and set font preferences and axes foreground colors for all plots you create using the Control System Toolbox. This figure shows the Style page. You have the following choices: • Grid — Activate grids by default in new plots • Font preferences — Set the font size, weight (bold), and angle (italic) • Colors — Specify the color vector to use for the axes foreground, which includes the X-Y axes, grid lines, and tick labels.
The Characteristics page has selections for response characteristics and phase wrapping. This figure shows the Characteristics page with default settings. The following are the available options for the Characteristics page: • Response Characteristics: - Specify settling time tolerance — You can set the threshold of the settling time calculation to any percentage from 0 to 100%. The default is 2%.
7 Setting Toolbox Preferences The SISO Tool page has settings for the SISO Design Tool. This figure shows the SISO Tool page with default settings. You can make the following selections: • Compensator Format — You can select either the time-constant format or the zero/pole/gain format. The time-constant format is ( 1 + Tz 1 s ) dcgain × ---------------------------- … ( 1 + Tp1 s ) where Tz1, Tz2, ..., are the zero time constants, and Tp1, Tp2, ..., are the pole time constants.
8 Setting Tool Preferences Opening the LTI Viewer Preferences Editor Units Page . . . . . . . . . . . . . Style Page . . . . . . . . . . . . . Characteristics Page . . . . . . . . . Parameters Page . . . . . . . . . . . Opening the SISO Tool Preferences Editor Units Page . . . . . . . . . . . . . Style Page . . . . . . . . . . . . . Options Page . . . . . . . . . . . . Line Colors Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8 Setting Tool Preferences Both the LTI Viewer and the SISO Design Tool have Tool Preferences Editors. These editors comprise the middle layer of “The Property and Preferences Hierarchy”. Both editors allow you to set default characteristics for specific instances of LTI Viewers and SISO Design Tools. If you open a new instance of either, each defaults to the characteristics specified in the Toolbox Preferences editor.
Units Page Note Click on the page tabs below to get help on LTI Viewer Preference editor pages. You can select the following on the Units page (shown in Figure 8-1): • Frequency — Radians per second (rad/sec) or Hertz (Hz) • Magnitude — Decibels (dB) or absolute value (abs) • Phase — Degrees or radians For frequency and magnitude axes, you can select logarithmic or linear scales. Style Page Note Click on the page tabs below to get help on LTI Viewer Preference editor pages.
8 Setting Tool Preferences Use the Style page to toggle grid visibility and set font preferences and axes foreground colors for all plots in the LTI Viewer. This figure shows the Style page. You have the following choices: • Grid — Activate grids for all plots in the LTI Viewer • Fonts — Set the font size, weight (bold), and angle (italic) • Colors — Specify the color vector to use for the axes foreground, which includes the X-Y axes, grid lines, and tick labels.
The Characteristics page, shown below, has selections for response characteristics and phase wrapping. The following choices are available: • Response Characteristics: - Specify settling time tolerance — You can set the threshold of the settling time calculation to any percentage from 0 to 100%. The default is 2%. - Specify rise time boundaries — The standard definition of rise time is the time it takes the signal to go from 10% to 90% of the final value.
8 Setting Tool Preferences Use the Parameters page, shown below, to specify input vectors for time and frequency simulation. The defaults are to generate time and frequency vectors for your plots automatically. You can, however, override the defaults as follows: • Time Vector: - Define stop time — Specify the final time value for your simulation - Define vector — Specify the time vector manually using equal-sized time steps • Frequency Vector: - Define range — Specify the bandwidth of your response.
To open the SISO Tool Preferences editor, select SISO Tool Preferences from the Edit menu of the SISO Design Tool. This window opens. Figure 8-2: The SISO Tool Preferences Editor Units Page Note Click on the page tabs below to get help on SISO Tool Preference editor pages.
8 Setting Tool Preferences The Units page has settings for the following units: • Frequency — Radians per second (rad/sec) or Hertz (Hz) • Magnitude — Decibels (dB) or absolute value (abs) • Phase — Degrees or radians For frequency and magnitude axes, you can select logarithmic or linear scales. Style Page Note Click on the page tabs below to get help on SISO Tool Preference editor pages.
Colors Panel Specify the color vector to use for the axes foreground, which includes the X-Y axes, grid lines, and tick labels. Use a three-element vector to represent red, green, and blue (RGB) values. Vector element values can range from 0 to 1. Select colors. Press the Select button to open the Select Color window for the axes foreground. You can use this window to choose axes foreground colors without having to set RGB (red-green-blue) values numerically.
8 Setting Tool Preferences the Define Custom Colors button. This extends the Select Color window, as shown in this figure. You can pick colors from the color spectrum located in the upper right corner of the window. To select a custom color, follow these steps: 1 Place your cursor at a point in the color spectrum that has a color you want to define. 2 Left-click. Notice that the hue, saturation, luminescence (lum.), red, green, and blue fields specify the numerical values for the selected color.
The Options page, shown below, has selections for compensator format and Bode diagrams. You can make the following selections: • Compensator Format — Select either the time-constant format or the zero/pole/gain format. The time-constant format is ( 1 + Tz 1 s ) dcgain × ---------------------------- … ( 1 + Tp 1 s ) where Tz1, Tz2, ..., are the zero time constants, and Tp1, Tp2, ..., are the pole time constants. The zero/pole/gain format is a variation on the time-constant format.
8 Setting Tool Preferences Line Colors Page Note Click on the page tabs below to get help on SISO Tool Preference editor pages. The Line Colors page, shown below, has selections for specify the colors of the lines in the response plots of the SISO Design Tool. Click on the Select button for help on choosing colors. To change the colors of plot lines associated with parts of your model, specify a three-element vector to represent red, green, and blue (RGB) values.
9 Customizing Response Plot Properties Property Editor . Labels Page . . . . Limits Page . . . . Units Page . . . . Style Page . . . . Characteristics Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 9-4 9-4 9-5 9-7 9-8 Property Editing for Subplots . . . . . . . . . . . .
9 Customizing Response Plot Properties The lowest level of “The Property and Preferences Hierarchy” is setting response plot properties. If you have created a response plot, there are two ways to open the Property Editor: • Double-click in the plot region • Select Properties from the right-click menu Before looking at the Property Editor, open a step response plot using this commands. load ltiexamples step(sys_dc) This creates a step plot. Select Properties from the right-click window.
Property Editor Property Editor Note Click on the page tabs below to get help on pages in the Property Editor. This figure shows the Property Editor for this step response. Figure 9-2: The Property Editor for the Step Response In general, you can change the following properties of response plots: • Labels — Titles and X- and Y-labels • Limits — Numerical ranges of the X and Y axes • Units — Where applicable (e.g., rad/sec to Hertz).
9 Customizing Response Plot Properties As you make changes in the Property Editor, they display immediately in the response plot. Conversely, if you make changes in a plot using right-click menus, the Property Editor for that plot automatically updates. The Property Editor and its associated plot are dynamically linked. Labels Page Note Click on the page tabs below to get help on pages in the Property Editor.
Property Editor The Control System Toolbox selects default values for the axes limits to make sure that the maximum and minimum x and y values are displayed. If you want to override the default settings, change the values in the Limits fields. The Auto-Scale box automatically unchecks if you click on a different field. The new limits appear immediately in the response plot. To reestablish the default values, recheck the Auto-Scale box.
9 Customizing Response Plot Properties You can use the units page to change units in your response plot. The contents of this page depend on the response plot associated with the editor. Note that for step and impulse responses, there are no alternate units available (only time and amplitude are possible in the toolbox). This table lists the options available for the other response objects. Use the menus to toggle between units.
Property Editor Table 9-1: Optional Unit Conversions for Response Plots Response Plot Unit Conversions Singular Values Frequency in rad/sec or Hertz using logarithmic or linear scale Magnitude in decibels or the absolute value Step None Style Page Note Click on the page tabs below to get help on pages in the Property Editor. Use the Style page to toggle grid visibility and set font preferences and axes foreground colors for response plots.
9 Customizing Response Plot Properties • Colors — Specify the color vector to use for the axes foreground, which includes the X-Y axes, grid lines, and tick labels. Use a three-element vector to represent red, green, and blue (RGB) values. Vector element values can range from 0 to 1. If you do not want to specify RGB values numerically, press the Select button to open the Select Colors window. See “Select colors” for more information.
Property Editor them. Use the checkboxes to activate the feature and the fields to specify rise or settling time percentages.
9 Customizing Response Plot Properties Property Editing for Subplots If you create more than one plot in a single figure window, you can edit each plot individually. For example, the following code creates a figure with two plots, a step and an impulse response with two randomly selected systems. subplot(2,1,1) step(rss(2,1)) subplot(2,1,2) impulse(rss(1,1)) After the figure window appears, double-click in the upper (step response) plot to activate the Property Editor.
Customizing Plots Inside the SISO Design Tool Customizing Plots Inside the SISO Design Tool Customizing plots inside the SISO Design Tool is similar to how you customize any response plot. The Control System Toolbox provides a property editor specific to the SISO Design Tool that you can use to create custom root locus and Bode diagrams within the SISO Design Tool.
9 Customizing Response Plot Properties Labels Page Note Click on the page tabs below to get help on pages in the Root Locus Property Editor. You can use the Label page to specify plot titles and axis labels. To specify a new label, type the string in the appropriate field. The root locus plot automatically updates. Limits Page Note Click on the page tabs below to get help on pages in the Root Locus Property Editor.
Customizing Plots Inside the SISO Design Tool root locus plot. Use the Limits page, shown below, to override the default settings. To change the limits, specify the new limits in the real and imaginary axes Limits fields. The Auto-Scale checkbox automatically deactivates once you click in a different field. Your root locus diagram updates immediately. If you want to reapply the default limits, recheck the Auto-Scale checkboxes.
9 Customizing Response Plot Properties Using these buttons, you can store and retrieve any number of saved custom axes limits. Options Page Note Click on the page tabs below to get help on pages in the Root Locus Property Editor. The Options page contains settings for adding a grid and changing the plot’s aspect ratio. This figure shows the Options page. Check Show grid to display a grid on the root locus.
Customizing Plots Inside the SISO Design Tool at the MATLAB prompt and import Gservo from the workspace into your SISO Design Tool. Figure 9-3: Displaying Damping Ratio Values The numbers displayed on the root locus gridlines are the damping ratios as a percentage of the overshoot values. If you check the Equal box in the Aspect Ratio panel, the x and y-axes are set to equal limit values.
9 Customizing Response Plot Properties • Select Bode and then Properties from Edit in the menu bar Note Click on the page tabs below to get help on pages in the Bode Diagram Property Editor. This figure shows the Property Editor: Bode Diagram editor. Labels Page Note Click on the page tabs below to get help on pages in the Bode Diagram Property Editor.
Customizing Plots Inside the SISO Design Tool You can use the Label page to specify plot titles and axis labels. To specify a new label, type the string in the appropriate field. The Bode diagram automatically updates. Limits Page Note Click on the page tabs below to get help on pages in the Bode Diagram Property Editor.
9 Customizing Response Plot Properties The Control System Toolbox sets default limits for the frequency, magnitude, and phase scales for your plots. Use the Limits page to override the default values. To change the limits, specify the new values in the Limits fields for frequency, magnitude, and phase. The Auto-Scale checkbox automatically deactivates once you click in a different field. The Bode diagram updates immediately. To restore the default settings, recheck the Auto-Scale boxes.
Customizing Plots Inside the SISO Design Tool This figure shows the Options page for Bode diagrams. The following options are available from this page: • Grid — Check Show grid to display grid lines. • Magnitude/Phase — There are three radio buttons; you can toggle between the following displays: - Show magnitude & phase - Show magnitude only - Show phase only • Response Characteristics — Check Show stability margins to display the phase and gain margins on your Bode diagram.
9 Customizing Response Plot Properties 9-20
10 Design Case Studies Yaw Damper for a 747 Jet Transport Open-Loop Analysis . . . . . . . . Root Locus Design . . . . . . . . . Washout Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3 . 10-5 . 10-9 10-14 Hard-Disk Read/Write Head Controller . . . . . . . 10-20 LQG Regulation: Rolling Mill Example Process and Disturbance Models . . . . LQG Design for the x-Axis . . . . . . . LQG Design for the y-Axis . . . . . . . Cross-Coupling Between Axes . . .
10 Design Case Studies This chapter contains four detailed case studies of control system design and analysis using the Control System Toolbox.
Yaw Damper for a 747 Jet Transport Yaw Damper for a 747 Jet Transport This case study demonstrates the tools for classical control design by stepping through the design of a yaw damper for a 747 jet transport aircraft. The jet model during cruise flight at MACH = 0.8 and H = 40,000 ft. is A = [-0.0558 0.5980 -3.0500 0 B = [ 0.0729 -4.7500 .15300 0 C = [0 0 1 0 D = [0 0 0 0]; -0.9968 -0.1150 0.3880 0.0805 0.0802 -0.0318 -0.4650 1.0000 0.0415 0 0 0]; 0.0000 0.00775 0.
10 Design Case Studies b = beta yaw roll phi rudder 0.0729 -4.75 0.153 0 aileron 0 0.00775 0.143 0 yaw bank angle beta 0 0 yaw 1 0 rudder 0 0 aileron 0 0 c = roll 0 0 phi 0 1 d = yaw bank angle Continuous-time model. The model has two inputs and two outputs. The units are radians for beta (sideslip angle) and phi (bank angle) and radians/sec for yaw (yaw rate) and roll (roll rate). The rudder and aileron deflections are in radians as well.
Yaw Damper for a 747 Jet Transport pzmap(sys) This model has one pair of lightly damped poles. They correspond to what is called the “Dutch roll mode.” Suppose you want to design a compensator that increases the damping of these poles, so that the resulting complex poles have a damping ratio ζ > 0.35 with natural frequency ω n < 1 rad/sec. You can do this using the Control System toolbox analysis tools. Open-Loop Analysis First, perform some open-loop analysis to determine possible control strategies.
10 Design Case Studies impulse(sys) The impulse response confirms that the system is lightly damped. But the time frame is much too long because the passengers and the pilot are more concerned about the behavior during the first few seconds rather than the first few minutes. Next look at the response over a smaller time frame of 20 seconds.
Yaw Damper for a 747 Jet Transport impulse(sys,20) Look at the plot from aileron (input 2) to bank angle (output 2). To show only this plot, right-click and choose I/O Selector, then click on the (2,2) entry. The I/O Selector should look like this.
10 Design Case Studies The new figure is shown below. The aircraft is oscillating around a nonzero bank angle. Thus, the aircraft is turning in response to an aileron impulse. This behavior will prove important later in this case study. Typically, yaw dampers are designed using the yaw rate as sensed output and the rudder as control input. Look at the corresponding frequency response. sys11=sys('yaw','rudder') % Select I/O pair.
Yaw Damper for a 747 Jet Transport bode(sys11) From this Bode diagram, you can see that the rudder has significant effect around the lightly damped Dutch roll mode (that is, near ω = 1 rad/sec). Root Locus Design A reasonable design objective is to provide a damping ration ζ > 0.35 with a natural frequency ω n < 1.0 rad/sec. Since the simplest compensator is a static gain, first try to determine appropriate gain values using the root locus technique.
10 Design Case Studies rlocus(sys11) This is the root locus for negative feedback and shows that the system goes unstable almost immediately. If, instead, you use positive feedback, you may be able to keep the system stable.
Yaw Damper for a 747 Jet Transport sgrid This looks better. By using simple feedback, you can achieve a damping ratio of ζ = 0.45 .
10 Design Case Studies gain and damping values. To achieve a 0.45 damping ratio, the gain should be about 2.85. This figure shows the data marker with similar values. Next, close the SISO feedback loop. K = 2.85; cl11 = feedback(sys11,-K); % Note: feedback assumes negative % feedback by default Plot the closed-loop impulse response for a duration of 20 seconds, and compare it to the open-loop impulse response.
Yaw Damper for a 747 Jet Transport impulse(sys11,'b--',cl11,'r',20) The closed-loop response settles quickly and does not oscillate much, particularly when compared to the open-loop response. Now close the loop on the full MIMO model and see how the response from the aileron looks. The feedback loop involves input 1 and output 1 of the plant (use feedback with index vectors selecting this input/output pair).
10 Design Case Studies Plot the MIMO impulse response. impulse(sys,'b--',cloop,'r',20) The yaw rate response is now well damped, but look at the plot from aileron (input 2) to bank angle (output 2). When you move the aileron, the system no longer continues to bank like a normal aircraft. You have over-stabilized the spiral mode. The spiral mode is typically a very slow mode and allows the aircraft to bank and turn without constant aileron input.
Yaw Damper for a 747 Jet Transport The washout filter places a zero at the origin, which constrains the spiral mode pole to remain near the origin. We choose a = 0.2 for a time constant of five seconds and use the root locus technique to select the filter gain H. First specify the fixed part s ⁄ ( s + a ) of the washout by H = zpk(0,-0.
10 Design Case Studies This figure shows a data marker at the maximum damping ratio; the gain is approximately 2.07. Look at the closed-loop response from rudder to yaw rate. K = 2.
Yaw Damper for a 747 Jet Transport impulse(cl11,20) The response settles nicely but has less damping than your previous design. Finally, you can verify that the washout filter has fixed the spiral mode problem. First form the complete washout filter kH ( s ) (washout + gain). WOF = -K * H; Then close the loop around the first I/O pair of the MIMO model sys and simulate the impulse response.
10 Design Case Studies % Final closed-loop impulse response impulse(sys,'b--',cloop,'r',20) The bank angle response (output 2) due to an aileron impulse (input 2) now has the desired nearly constant behavior over this short time frame.
Yaw Damper for a 747 Jet Transport response more closely, use the I/O Selector in the right-click menu to select the (2,2) I/O pair. Although you did not quite meet the damping specification, your design has increased the damping of the system substantially and now allows the pilot to fly the aircraft normally.
10 Design Case Studies Hard-Disk Read/Write Head Controller Hard Disk Drive Disk Platen Ω Disk Drive Motor Read/Write Head l θ Solenoid This case study demonstrates the ability to perform classical digital control design by going through the design of a computer hard-disk read/write head position controller.
Hard-Disk Read/Write Head Controller num = Ki; den = [J C K]; H = tf(num,den) MATLAB responds with Transfer function: 0.05 ----------------------0.01 s^2 + 0.004 s + 10 The task here is to design a digital controller that provides accurate positioning of the read/write head. The design is performed in the digital domain. First, discretize the continuous plant.
10 Design Case Studies bode(H,'-',Hd,'--') To analyze the discrete system, plot its step response, type 10-22
Hard-Disk Read/Write Head Controller step(Hd) The system oscillates quite a bit. This is probably due to very light damping. You can check this by computing the open-loop poles. Type % Open-loop poles of discrete model damp(Hd) Eigenvalue 9.87e-01 + 1.57e-01i 9.87e-01 - 1.57e-01i Magnitude 9.99e-01 9.99e-01 Equiv. Damping 6.32e-03 6.32e-03 Equiv. Freq. 3.16e+01 3.16e+01 The poles have very light equivalent damping and are near the unit circle.
10 Design Case Studies rlocus(Hd) As shown in the root locus, the poles quickly leave the unit circle and go unstable. You need to introduce some lead or a compensator with some zeros. Try the compensator z+a D ( z ) = -----------z+b with a = – 0.85 and b = 0 .
Hard-Disk Read/Write Head Controller D = zpk(0.85,0,1,Ts) oloop = Hd * D Now see how this compensator modifies the open-loop frequency response. bode(Hd,'--',oloop,'-') The plant response is the dashed line and the open-loop response with the compensator is the solid line. The plot above shows that the compensator has shifted up the phase plot (added lead) in the frequency range ω > 10 rad/sec. Now try the root locus again with the plant and compensator as open loop.
10 Design Case Studies Open the Property Editor by right-clicking in the plot away from the curve. On the Limits page, set the x-axis limits from -1 to 1.01. This figure shows the result. This time, the poles stay within the unit circle for some time (the lines drawn by zgrid show the damping ratios from ζ = 0 to 1 in steps of 0.1).
Hard-Disk Read/Write Head Controller marker to find the point on the curve where the gain equals 4.111e+03. This figure shows the data marker at the correct location. To analyze this design, form the closed-loop system and plot the closed-loop step response. K = 4.
10 Design Case Studies step(cloop) This response depends on your closed loop set point. The one shown here is relatively fast and settles in about 0.07 seconds. Therefore, this closed loop disk drive system has a seek time of about 0.07 seconds. This is slow by today's standards, but you also started with a very lightly damped system. Now look at the robustness of your design. The most common classical robustness criteria are the gain and phase margins. Use the function margin to determine these margins.
Hard-Disk Read/Write Head Controller oloop u + D(z) – Plant y k Next apply margin to this open-loop model. Type [Gm,Pm,Wcg,Wcp] = margin(olk); Margins = [Gm Wcg Pm Wcp] Margins = 3.7987 296.7978 43.2031 106.2462 To obtain the gain margin in dB, type 20*log10(Gm) ans = 11.
10 Design Case Studies The command produces the plot shown below. This design is robust and can tolerate a 11 dB gain increase or a 40 degree phase lag in the open-loop system without going unstable. By continuing this design process, you may be able to find a compensator that stabilizes the open-loop system and allows you to reduce the seek time.
LQG Regulation: Rolling Mill Example LQG Regulation: Rolling Mill Example This case study demonstrates the use of the LQG design tools in a process control application. The goal is to regulate the horizontal and vertical thickness of the beam produced by a hot steel rolling mill. This example is adapted from [1]. The full plant model is MIMO and the example shows the advantage of direct MIMO LQG design over separate SISO designs for each axis.
10 Design Case Studies This shape is impressed by two pairs of rolling cylinders (one per axis) positioned by hydraulic actuators. The gap between the two cylinders is called the roll gap. rolling mill stand incoming beam shaped beam x-axis rolling cylinders The objective is to maintain the beam thickness along the x- and y-axes within the quality assurance tolerances.
LQG Regulation: Rolling Mill Example This leads to the following generic model for each axis of the rolling process.
10 Design Case Studies Model Data for the x-Axis 8 2.4 × 10 H x ( s ) = ------------------------------------2 2 s + 72s + 90 4 10 F ix ( s ) = -------------------s + 0.05 4 3 × 10 s F ex ( s ) = -----------------------------------------2 2 s + 0.125s + 6 g x = 10 –6 Model Data for the y-Axis 8 7.8 × 10 H y ( s ) = ------------------------------------2 2 s + 71s + 88 4 2 × 10 F iy ( s ) = -------------------s + 0.05 5 10 s F ey ( s ) = -------------------------------------------2 2 s + 0.19s + 9.
LQG Regulation: Rolling Mill Example % Input thickness/hardness disturbance model Fix = tf(1e4,[1 0.05],'inputn','w-ix') % Rolling eccentricity model Fex = tf([3e4 0],[1 0.125 6^2],'inputn','w-ex') % Gain from force to thickness gap gx = 1e-6; Next build the open-loop model shown in Figure 10-1 above. You could use the function connect for this purpose, but it is easier to build this model by elementary append and series connections.
10 Design Case Studies ans = 'x-gap' 'x-force' The second output 'x-force' is the rolling force measurement. The LQG regulator will use this measurement to drive the hydraulic actuator and reduce disturbance-induced thickness variations δ x . The LQG design involves two steps: 1 Design a full-state-feedback gain that minimizes an LQ performance measure of the form J ( ux ) = ∞ 2 2 ò0 î qδx + rux þdt 2 Design a Kalman filter that estimates the state vector given the force measurements 'x-force'.
LQG Regulation: Rolling Mill Example Note: lqry expects all inputs to be commands and all outputs to be measurements. Here the command 'u-x' and the measurement 'x-gap*' (filtered gap) are the first input and first output of Pxdes. Hence, use the syntax Pxdes(1,1) to specify just the I/O relation between 'u-x' and 'x-gap*'. Next, design the Kalman estimator with the function kalman. The process noise wx = w ex w ix has unit covariance by construction.
10 Design Case Studies bode(Regx,{0.1 1000}) The phase response has an interesting physical interpretation. First, consider an increase in input thickness. This low-frequency disturbance boosts both output thickness and rolling force. Because the regulator phase is approximately 0o at low frequencies, the feedback loop then adequately reacts by increasing the hydraulic force to offset the thickness increase. Now consider the effect of eccentricity.
LQG Regulation: Rolling Mill Example 'u-x' 'w-ex' 'w-ix' Regx.outputname ans = 'u-x' Px.outputname ans = 'x-gap' 'x-force' Regx.inputname ans = 'x-force' This indicates that you must connect the first input and second output of Px to the regulator. clx = feedback(Px,Regx,1,2,+1) % Note: +1 for positive feedback You are now ready to compare the open- and closed-loop Bode responses from disturbance to thickness gap.
10 Design Case Studies bode(Px(1,2:3),'--',clx(1,2:3),'-',{0.1 100}) The dashed lines show the open-loop response. Note that the peak gain of the eccentricity-to-gap response and the low-frequency gain of the input-thickness-to-gap response have been reduced by about 20 dB. Finally, use lsim to simulate the open- and closed-loop time responses to the white noise inputs w ex and w ix . Choose dt=0.
LQG Regulation: Rolling Mill Example lsim(Px(1,2:3),':',clx(1,2:3),'-',wx,t) The dotted lines correspond to the open-loop response. In this simulation, the LQG regulation reduces the peak thickness variation by a factor 4. LQG Design for the y-Axis The LQG design for the y -axis (regulation of the y thickness) follows the exact same steps as for the x -axis. % Specify model components Hy = tf(7.8e8,[1 71 88^2],'inputn','u-y') Fiy = tf(2e4,[1 0.05],'inputn','w-iy') Fey = tf([1e5 0],[1 0.19 9.
10 Design Case Studies % State-feedback gain design Pydes = append(lpf,1) * Py % Add low-freq. weigthing set(Pydes,'outputn',{'y-gap*' 'y-force'}) ky = lqry(Pydes(1,1),1,1e-4) % Kalman estimator design esty = kalman(Pydes(2,:),eye(2),1e3) % Form SISO LQG regulator for y-axis and close the loop Regy = lqgreg(esty,ky) cly = feedback(Py,Regy,1,2,+1) Compare the open- and closed-loop response to the white noise input disturbances. dt = 0.
LQG Regulation: Rolling Mill Example lsim(Py(1,2:3),':',cly(1,2:3),'-',wy,t) The dotted lines correspond to the open-loop response. The simulation results are comparable to those for the x -axis. Cross-Coupling Between Axes The x / y thickness regulation, is a MIMO problem. So far you have treated each axis separately and closed one SISO loop at a time. This design is valid as long as the two axes are fairly decoupled.
10 Design Case Studies The coupling between axes is as follows. + δx + ux x-axis w ex model gx w ix – + g xy fx g yx + – uy fy y-axis w ey w iy model gy + + δy g xy = 0.1 g yx = 0.4 Figure 10-2: Coupling between the x- and y-axes Accordingly, the thickness gaps and rolling forces are related to the outputs δ x, f x, ...
LQG Regulation: Rolling Mill Example 0 1 – g yx fx 0 0 – g xy 1 fy 0 δy 0 g xy g y 1 0 δx gyx g x ì fy 0 fx = 0 δy 1 δx cross-coupling matrix Let’s see how the previous “decoupled” LQG design fares when cross-coupling is taken into account. To build the two-axes model shown in Figure 10-2, append the models Px and Py for the x - and y-axes.
10 Design Case Studies lsim(Pc(1:2,3:6),':',cl(1:2,3:6),'-',wxy,t) The response reveals a severe deterioration in regulation performance along the x-axis (the peak thickness variation is about four times larger than in the simulation without cross-coupling). Hence, designing for one loop at a time is inadequate for this level of cross-coupling, and you must perform a joint-axis MIMO design to correctly handle coupling effects.
LQG Regulation: Rolling Mill Example 'w_ey' 'w_iy' P.outputname ans = 'x-gap' 'y-gap' 'x-force' 'y-force' As earlier, add low-pass filters in series with the 'x-gap' and 'y-gap' outputs to penalize only low-frequency thickness variations. Pdes = append(lpf,lpf,eye(2)) * Pc Pdes.outputn = Pc.outputn Next, design the LQ gain and state estimator as before (there are now two commands and two measurements).
10 Design Case Studies sigma(RegMIMO) Next, plot the open- and closed-loop time responses to the white noise inputs (using the MIMO LQG regulator for feedback).
LQG Regulation: Rolling Mill Example lsim(Pc(1:2,3:6),':',cl(1:2,3:6),'-',wxy,t) The MIMO design is a clear improvement over the separate SISO designs for each axis. In particular, the level of x / y thickness variation is now comparable to that obtained in the decoupled case. This example illustrates the benefits of direct MIMO design for multivariable systems.
10 Design Case Studies Kalman Filtering This final case study illustrates the use of the Control System Toolbox for Kalman filter design and simulation. Both steady-state and time-varying Kalman filters are considered. Consider the discrete plant x [ n + 1 ] = Ax [ n ] + B ( u [ n ] + w [ n ] ) y [ n ] = Cx [ n ] with additive Gaussian noise w [ n ] on the input u [ n ] and data A = [1.1269 1.0000 0 -0.4940 0 1.0000 0.1129 0 0]; B = [-0.3832 0.5919 0.
Kalman Filtering In these equations: • x̂ [ n n – 1 ] is the estimate of x [ n ] given past measurements up to y v [ n – 1 ] • x̂ [ n n ] is the updated estimate based on the last measurement y v [ n ] Given the current estimate x̂ [ n n ] , the time update predicts the state value at the next sample n + 1 (one-step-ahead predictor). The measurement update then adjusts this prediction based on the new measurement y v [ n + 1 ] . The correction term is a function of the innovation, that is, the discrepancy.
10 Design Case Studies 'outputname','y'); Assuming that Q = R = 1 , you can now design the discrete Kalman filter by Q = 1; R = 1; [kalmf,L,P,M] = kalman(Plant,Q,R); This returns a state-space model kalmf of the filter as well as the innovation gain M M = 3.7980e-01 8.1732e-02 -2.5704e-01 The inputs of kalmf are u and y v , and its outputs are the plant output and state estimates y e = ŷ [ n n ] and x̂ [ n n ] .
Kalman Filtering x2_e x3_e 0.5919 0.5191 0.3798 0.081732 y_e x1_e 0.6202 x2_e 0 y_e u 0 y 0.3798 c = x3_e 0 d = I/O groups: Group name KnownInput Measurement OutputEstimate I/O I I O Channel(s) 1 2 1 Sampling time: unspecified Discrete-time model. To see how the filter works, generate some input data and random noise and compare the filtered response y e with the true response y . You can either generate each response separately, or generate both together.
10 Design Case Studies You can construct a state-space model of this block diagram with the functions parallel and feedback. First build a complete plant model with u, w, v as inputs and y and y v (measurements) as outputs. a b c d P = = = = = A; [B B 0*B]; [C;C]; [0 0 0;0 0 1]; ss(a,b,c,d,-1,'inputname',{'u' 'w' 'v'},... 'outputname',{'y' 'yv'}); Then use parallel to form the following parallel connection.
Kalman Filtering 'v' 'u' SimModel.outputname ans = 'y' 'y_e' You are now ready to simulate the filter behavior. Generate a sinusoidal input u and process and measurement noise vectors w and v . t = [0:100]'; u = sin(t/5); n = length(t) randn('seed',0) w = sqrt(Q)*randn(n,1); v = sqrt(R)*randn(n,1); Now simulate with lsim.
10 Design Case Studies xlabel('No. of samples'), ylabel('Error') The first plot shows the true response y (dashed line) and the filtered output y e (solid line). The second plot compares the measurement error (dash-dot) with the estimation error (solid). This plot shows that the noise level has been significantly reduced. This is confirmed by the following error covariance computations. MeasErr = y-yv; MeasErrCov = sum(MeasErr.*MeasErr)/length(MeasErr); EstErr = y-ye; EstErrCov = sum(EstErr.
Kalman Filtering EstErrCov EstErrCov = 0.2722 Time-Varying Kalman Filter The time-varying Kalman filter is a generalization of the steady-state filter for time-varying systems or LTI systems with nonstationary noise covariance.
10 Design Case Studies For simplicity, we have dropped the subscripts indicating the time dependence of the state-space matrices. Given initial conditions x [ 1 0 ] and P [ 1 0 ] , you can iterate these equations to perform the filtering. Note that you must update both the state estimates x [ n . ] and error covariance matrices P [ n . ] at each time sample.
Kalman Filtering x = A*x + B*u(i); P = A*P*A' + B*Q*B'; end % x[n+1|n] % P[n+1|n] You can now compare the true and estimated output graphically. subplot(211), plot(t,y,'--',t,ye,'-') title('Time-varying Kalman filter response') xlabel('No. of samples'), ylabel('Output') subplot(212), plot(t,y-yv,'-.',t,y-ye,'-') xlabel('No. of samples'), ylabel('Output') The first plot shows the true response y (dashed line) and the filtered response y e (solid line).
10 Design Case Studies plot(t,errcov), ylabel('Error covar') From this covariance plot, you can see that the output covariance did indeed reach a steady state in about five samples. From then on, your time-varying filter has the same performance as the steady-state version. Compare with the estimation error covariance derived from the experimental data. Type EstErr = y-ye; EstErrCov = sum(EstErr.*EstErr)/length(EstErr) EstErrCov = 0.
Kalman Filtering Mn = 0.3798 0.0817 -0.2570 M = 0.3798 0.0817 -0.2570 References [1] Grimble, M.J., Robust Industrial Control: Optimal Design Approach for Polynomial Systems, Prentice Hall, 1994, p. 261 and pp. 443-456.
10 Design Case Studies 10-62
11 Reliable Computations Conditioning and Numerical Stability . . . . . . . . 11-4 Conditioning . . . . . . . . . . . . . . . . . . . . 11-4 Numerical Stability . . . . . . . . . . . . . . . . . . 11-6 Choice of LTI Model State Space . . . . . Transfer Function . . Zero-Pole-Gain Models Scaling Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8 . 11-8 . 11-8 11-13 . . . . . . . . . . . . . . . . . . . . .
11 Reliable Computations When working with low-order SISO models (less than five states), computers are usually quite forgiving and insensitive to numerical problems. You generally won't encounter any numerical difficulties and MATLAB will give you accurate answers regardless of the model or conversion method you choose. For high order SISO models and MIMO models, however, the finite-precision arithmetic of a computer is not so forgiving and you must exercise caution.
At the same time, it is important to appreciate the limitations of computer analyses. By following a few guidelines, you can avoid certain tools and models when they are likely to get you into trouble. The following sections try to illustrate, through examples, some of the numerical pitfalls to be avoided. We also encourage you to get the most out of the good algorithms by ensuring, if possible, that your models give rise to problems that are well-conditioned.
11 Reliable Computations Conditioning and Numerical Stability Two of the key concepts in numerical analysis are the conditioning of problems and the stability of algorithms. Conditioning Consider the linear system Ax = b given by A = 0.7800 0.9130 0.5630 0.6590 b = 0.2170 0.2540 The true solution is x = [1, –1]' and you can calculate it approximately using MATLAB. x = A\b x = 1.0000 –1.0000 format long, x x = 0.99999999991008 –0.
Conditioning and Numerical Stability Notice how much the small change in the data is magnified in the solution. One way to measure the magnification factor is by means of the quantity A A –1 called the condition number of A with respect to inversion. The condition number determines the loss in precision due to roundoff errors in Gaussian elimination and can be used to estimate the accuracy of results obtained from matrix inversion and linear equation solution.
11 Reliable Computations row of A. This perturbed matrix has n distinct eigenvalues λ 1, ..., λ n with λ k = 1 ⁄ 2 exp ( j2πk ⁄ n ) . Thus, you can see that this small perturbation in the n data has been magnified by a factor on the order of 2 to result in a rather large perturbation in the solution (the eigenvalues of A). Further details and related examples are to be found in [7].
Conditioning and Numerical Stability Using row 1 as the pivot row (i.e., subtracting 1000 times row 1 from row 2) you arrive at the equivalent triangular system. 0.001 1.000 x1 0 – 1000 x 2 = 1.000 – 1000 Note that the coefficient multiplying x 2 in the second equation should be – 1001, but because of roundoff, becomes – 1000 . As a result, the second equation yields x2 = 1.000 , a good approximation, but now back-substitution in the first equation 0.001x 1 = 1.000 – ( 1.000 ) ( 1.000 ) yields x 1 = 0.
11 Reliable Computations Choice of LTI Model Now turn to the implications of the results in the last section on the linear modeling techniques used for control engineering. The Control System Toolbox includes the following types of LTI models that are applicable to discussions of computational reliability: • State space • Transfer function, polynomial form • Transfer function, factored zero-pole-gain form The following subsections show that state space is most preferable for numerical computations.
Choice of LTI Model A major difficulty is the extreme sensitivity of the roots of a polynomial to its coefficients. This example is adapted from Wilkinson, [6] as an illustration. Consider the transfer function 1 1 H ( s ) = ------------------------------------------------------------- = ----------------------------------------------------------20 19 ( s + 1 ) ( s + 2 )... ( s + 20 ) s + 210s + ... + 20! The A matrix of the companion realization of H ( s ) is A = 0 0 : 0 – 20! 1 0 : 0 . 0 1 . ... ...
11 Reliable Computations very little. This is true in general. Different roots have different sensitivities to different perturbations. Computed roots may then be quite meaningless for a polynomial, particularly high-order, with imprecisely known coefficients. Finding all the roots of a polynomial (equivalently, the poles of a transfer function or the eigenvalues of a matrix in controllable or observable canonical form) is often an intrinsically sensitive problem.
Choice of LTI Model 5.000000270433721e+00 5.999998194359617e+00 7.000004542844700e+00 8.000013753274901e+00 8.999848908317270e+00 1.000059459550623e+01 1.099854678336595e+01 1.200255822210095e+01 1.299647702454549e+01 1.400406940833612e+01 1.499604787386921e+01 1.600304396718421e+01 1.699828695210055e+01 1.800062935148728e+01 1.899986934359322e+01 2.000001082693916e+01 5.000000000000000e+00 6.000000000000000e+00 7.000000000000000e+00 8.000000000000000e+00 9.000000000000000e+00 1.000000000000000e+01 1.
11 Reliable Computations 0 0 0 10.0000 The condition number (with respect to inversion) of the eigenvector matrix is cond(v) ans = 1.000 Now convert a state-space model with the above A matrix to transfer function form, and back again to state-space form. b = [1 ; 1 ; 0 ; –1]; c = [0 0 2 1]; H = tf(ss(A,b,c,0)); [Ac,bc,cc] = ssdata(H) % transfer function % convert back to state space The new A matrix is Ac = 18.0000 16.0000 0 0 –6.0625 0 4.0000 0 2.8125 0 0 1.0000 –1.
Choice of LTI Model The condition number of the new eigenvector matrix cond(vc) ans = 34.5825 is thirty times larger. The phenomenon illustrated above is not unusual. Matrices in companion form or controllable/observable canonical form (like Ac) typically have worse-conditioned eigensystems than matrices in general state-space form (like A). This means that their eigenvalues and eigenvectors are more sensitive to perturbation. The problem generally gets far worse for higher-order systems.
11 Reliable Computations extraordinary arithmetic range difficulties of polynomial coefficients, as illustrated in the “Transfer Function” section. The transformation from state space to zero-pole-gain is stable, although the handling of infinite zeros can sometimes be tricky, and repeated roots can cause problems. If possible, avoid repeated switching between different model representations.
Scaling Scaling State space is the preferred model for LTI systems, especially with higher order models. Even with state-space models, however, accurate results are not guaranteed, because of the finite-word-length arithmetic of the computer. A well-conditioned problem is usually a prerequisite for obtaining accurate results. You should generally normalize or scale the ( A, B, C, D ) matrices of a system to improve their conditioning.
11 Reliable Computations entries are the smallest deviations that are significant to each variable. An excellent discussion of scaling is given in the introduction to the LINPACK Users’ Guide, [1]. Choose scaling based upon physical insight to the problem at hand. If you choose not to scale, and for many small problems scaling is not necessary, be aware that this choice affects the accuracy of your answers. Finally, note that the function ssbal performs automatic scaling of the state vector.
Summary Summary This chapter has described numerous things that can go wrong when performing numerical computations. You won’t encounter most of these difficulties when you solve practical lower-order problems. The problems described here pertain to all computer analysis packages. MATLAB has some of the best algorithms available, and, where possible, notifies you when there are difficulties.
11 Reliable Computations References [1] Dongarra, J.J., J.R. Bunch, C.B. Moler, and G.W. Stewart, LINPACK Users Guide, SIAM Publications, Philadelphia, PA, 1978. [2] Franklin, G.F. and J.D. Powell, Digital Control of Dynamic Systems, Addison-Wesley, 1980. [3] Kailath, T., Linear Systems, Prentice-Hall, 1980. [4] Laub, A.J., “Numerical Linear Algebra Aspects of Control Design Computations,” IEEE Transactions on Automatic Control, Vol. AC-30, No. 2, February 1985, pp. 97-108. [5] Wilkinson, J.H.
12 GUI Reference
12 GUI Reference The next three chapters discuss in detail all the features of the LTI Viewer and the SISO Design Tool. The LTI Viewer is a graphical user interface (GUI) that allows you to display up to six response plots in a single window. The SISO Design Tool is a GUI that facilitates the design of compensators for single-input single-output (SISO) systems. It supports both root locus and Bode diagram design techniques. This document is not meant as an introduction to these tools.
13 SISO Design Tool Reference Menu Bar . . . . . . . . . . . . . . . . . . . . . 13-4 Tool Bar . . . . . . . . . . . . . . . . . . . . . 13-23 Current Compensator . . . . . . . . . . . . . . . 13-24 Feedback Structure . . . . . . . . . . . . . . . 13-25 Root Locus Right-Click Menus . . . . . . . . . . . 13-26 Bode Diagram Right-Click Menus . . . . . . . . . 13-31 Status Panel . . . . . . . . . . . . . . . . . . .
13 SISO Design Tool Reference The SISO Design Tool is a graphical-user interface (GUI) that allows you to use root-locus and Bode diagram techniques to design compensators. The SISO Design Tool by default displays the root locus and Bode diagrams for your imported systems. The two are dynamically linked; for example, if you change the gain in the root locus, it immediately affects the Bode diagrams as well.
This document describes the SISO Design Tool features left-to-right and top-to-bottom, starting with the Menu bar and ending with the Status panel at the bottom of the window. If you want to match the SISO Design Tool pictures shown below, type load ltiexamples at the MATLAB prompt. This loads the same set of linear models that this document uses as examples in the GUI. The examples all use the Gservo system for plot displays.
13 SISO Design Tool Reference Menu Bar Note Click on items on the menu bar pictured below to get help contents. Most of the tasks you can do in the SISO Design Tool can be done from the menu bar, which this picture shows. File Note Click on items in the File menu pictured below to get help contents. . Using the File menu, you can: • Import and export models • Set toolbox preferences • Print and print to figure • Close the SISO Design Tool The following sections describe the File menu options in turn.
Menu Bar Import Select Import to import models into the SISO Design Tool. Selecting Import opens the Import System Data window, which is shown below. Press the Other button to switch to an alternate feedback structure, where C , the compensator, is in the feedback path. Figure 13-2: The Import System Data Window The following sections discuss the System Name, Import from, and System Data panels of the Import System Data window. System Name Use the Name field to assign a name to the imported system.
13 SISO Design Tool Reference • Feedback structure specification — Press Other to toggle between placing the compensator in the forward and feedback paths • Model import specification — You can import models for the plant (G), compensator (C), prefilter (F), and/or sensor (H). To import a model, select it from the SISO model list and press the right-arrow button next to the desired model field. Export Selecting Export from the File menu opens the SISO Tool Export Window.
Menu Bar they are adjacent on the list. If you want to save non-adjacent models, hold down the Ctrl key while selecting the models. 2 For each model you want to save, specify a name in the model’s cell in the Export As list. A default name exists if you do not want to assign a new name. 3 Press Export to Workspace. Exporting to a MAT-file If you want to save your models in a MAT-file, follow steps 1 and 2 and press Export to Disk, which opens this window.
13 SISO Design Tool Reference Toolbox Preferences Select Toolbox Preferences to open the Control System Toolbox Preferences menu. This picture shows the window.
Menu Bar Print to Figure Print to Figure opens a separate figure window containing the root locus and/or Bode diagrams in your current SISO Design Tool. Close Use Close to close the SISO Design Tool. Edit Note Click on items in the Edit menu pictured below to get help contents. . Undo and Redo Use Undo and Redo to go back and forward in the design steps. Note that both Undo and Redo menus change when the task you have just performed changes.
13 SISO Design Tool Reference SISO Tool Preferences SISO Tool Preferences opens the SISO Tool Preferences editor. This picture shows the open window. Figure 13-5: The SISO Tool Preferences Editor You can use this window to do the following: • Change units • Add plot grids, change font styles for titles, labels, etc., and change axes foreground colors • Change the compensator format and For a complete description of properties and preferences, see SISO Design Preferences.
Menu Bar Root Locus and Bode Diagrams By default, the SISO Design Tool displays the root locus and Bode magnitude and phase diagrams. You can deselect either to show only the root locus or the Bode diagram. System Data System Data opens the window shown below. Press any of these buttons to see the transfer function of the particular model. Figure 13-6: The System Data Window The System Data window displays basic information about the models you’ve imported.
13 SISO Design Tool Reference Closed Loop Poles Use this menu item to display the closed-loop pole values of the current system. Design History Selecting Design History opens the Design History window, which displays all the actions you’ve performed during a design session. You can save the history to an ASCII flat text file. Tools Note Click on items in the Tools menu pictured below to get help contents.
Menu Bar • Open-Loop Nyquist — The open-loop Nyquist plot for your system • Open-Loop Nichols — The open-loop Nichols plot for your system Customizing Loop Responses If you choose Custom from the list of loop responses, the Response Plot Setup window opens. Figure 13-7: Response Plot Setup Window This window has many options for creating more specialized response plots, but to use it properly you should be familiar with the basic features of the LTI Viewer.
13 SISO Design Tool Reference • Loop transfer — This is defined as the compensator (C), the plant (G), and the sensor (H) multiplied together (CGH). If you haven’t defined a sensor, its default value is 1. 1 • Sensitivity function — This is defined as ------------- , where L is the loop transfer 1+L function. Some of the open- and closed-loop responses use these definitions. See “Contents of plots” for more information. Plots. You can have up to six plots in one LTI Viewer.
Menu Bar Continuous/Discrete Conversions Selecting Continuous/Discrete Conversions opens the Continuous/Discrete Conversions window, which you can use to convert between continuous to discrete designs.You can select the following: • Conversion method • Sample time • Critical frequency (where applicable) This picture shows the window. Figure 13-8: The Continuous/Discrete Conversion Window Conversion domain.
13 SISO Design Tool Reference Conversion method. The following are the available continuous-to-discrete conversion methods: • Zero-order hold • First-order hold • Tustin • Tustin with prewarping • Matched pole/zero If you choose Tustin with prewarping, you must specify the critical frequency in rad/sec. Discrete-time domain. If you currently have a discrete-time system, the Continuous/Discrete Conversion window looks like this figure.
Menu Bar • Tustin with prewarping • Matched pole/zero Again, if you choose Tustin with prewarping, you must specify the critical frequency. Draw a Simulink Diagram Note: You must have a license for Simulink to use this feature. If you do not have Simulink, you will not see this option under the Tools menu. Select Draw a Simulink Diagram to draw a block diagram of your system (plant, compensator, prefilter, and sensor).
13 SISO Design Tool Reference Format Selecting Format under Compensator activates the SISO Tool Preferences editor with the Options page open. This figure shows the Options page. Use the radio buttons to toggle between time constant and zero/pole/gain compensator formats. By default, the SISO Design Tool shows the plant poles and zeros on the root locus and Bode diagrams as red x’s and o’s, respectively. Uncheck the Show plant/sensor poles and zeros box to hide the plant and sensor poles and zeros.
Menu Bar For a general description of the SISO Tool Preferences editor, see SISO Design Tool Preferences in the online documentation. Edit Selecting Edit under the Compensator menu opens the Edit Compensator window, which is shown below.
13 SISO Design Tool Reference Adding poles and zeros To add real poles to your compensator, press Add Real Pole. This action opens an empty field in the Poles panel. Specify the pole value in the field. To add a pair of complex poles, press Add Complex Pole. In this case, two fields appear: one for the real and another for the imaginary part of the poles.
Menu Bar Retrieve Retrieve opens the Compensator Designs window, shown in the figure below. This window lists all the compensator designs you have stored during a Control System Toolbox session. To retrieve a stored design, left-click on the compensator’s name to select it and press Retrieve. To delete a design, select it and press the Delete button. Clear Select Clear to eliminate any compensator dynamics and set the gain to 1. Window The Window menu item lists all window open in MATLAB.
13 SISO Design Tool Reference Each topics takes you to a different place in the online documentation: • Main Help — The top of this document (SISO Tool Reference documentation) • Edit Compensator Window — “The Edit Compensator Window” section of this document.
Tool Bar Tool Bar The tool bar performs the following operations: • Add and delete real and complex poles and zeros • Zoom in and out • Invoke the SISO Design Tool’s context-sensitive help This picture shows the tool bar.
13 SISO Design Tool Reference Current Compensator The Current Compensator panel shows the structure of the compensator you are designing. The default compensator structure is a unity gain with no dynamics. Once you add poles and/or zeros, the Current Compensator panel displays the compensator in zero/pole/gain format. This picture shows a Current Compensator panel with Gcl1 entered as the compensator. You can change the gain of the compensator by changing the number in the text field.
Feedback Structure Feedback Structure To the right of the Current Compensator panel is the Feedback Structure panel, which is shown in its default configuration below. Figure 13-11: The Feedback Structure Panel To switch to the alternate feedback structure, press the FS button. This figure shows the new feedback structure. Figure 13-12: Alternate Feedback Structure with the Compensator in the Feedback Loop Pressing the +/- button toggles between positive and negative feedback signs.
13 SISO Design Tool Reference Root Locus Right-Click Menus Note Click on items in the right-click menu pictured below to get help contents. . Note that the menus are slightly different from those of the Bode diagram right-click menus. See “Bode Diagram Right-Click Menus” for a description of those menus. Add The Add menu options give you the ability to add dynamics to your compensator design. This figure shows the Add submenu.
Root Locus Right-Click Menus • Complex Zero • Differentiator (zero at 0) • Lead • Lag • Notch In all but the integrator and differentiator, once you select the configuration, your cursor changes to an ‘x’. To add the item to your compensator design, place the x at the desired location on the plot and left-click your mouse. You will see the root locus design automatically update to include the new compensator dynamics. The notch filter has three adjustable parameters.
13 SISO Design Tool Reference Design Constraints Select Design Constraints to open the Design Constraints window, which is shown below. You have the following options: • Settling Time • Peak Overshoot (%) • Damping Ratio • Natural Frequency Settling Time You can Peak Overshoot Damping Ratio Natural Frequency Grid Grid adds a grid to the root locus.
Root Locus Right-Click Menus Zoom Selecting Zoom opens this submenu. You have the following zooming options: • X-Y — Enlarge a selected area in the X-Y region. To do this, select X-Y, hold down your mouse’s left button, and drag to create a box region on the root locus. When you release the left button, the selected area becomes the entire plot region. • In-X — Zoom in, X-axis only. To do this, select In-X, hold down your mouse’s left button, and drag horizontally to create a line parallel to the X-axis.
13 SISO Design Tool Reference Properties Properties opens the Property Editor for the root locus. This picture shows the open window. You can use this window to change titles and axis labels, reset axes limits, add grid lines, and change the aspect ratio of the plot. For a complete discussion of the Property Editor for root locus, see Customizing Plots Inside the SISO Design Tool. You can also activate this menu by double-clicking anywhere in the root locus away from the curve.
Bode Diagram Right-Click Menus Bode Diagram Right-Click Menus Note Click on items in the right-click menu pictured below to get help contents. . Add The Add menu options give you the ability to add dynamics to your compensator design. This figure shows the Add submenu.
13 SISO Design Tool Reference • Lead • Lag • Notch In all but the integrator and differentiator, once you select the configuration, your cursor changes to an ‘x’. To add the item to your compensator design, place the x at the desired location on the plot and left-click your mouse. You will see the root locus design automatically update to include the new compensator dynamics. The notch filter has three adjustable parameters.
Bode Diagram Right-Click Menus Show Use Show to select/deselect the display of magnitude, phase, and stability margins. This figure displays the Show submenu. Selecting any of these three options toggles between showing and hiding the feature. A check next to the feature means that it is currently displayed on the Bode diagram plots. Zoom Selecting Zoom opens this submenu. You have the following zooming options: • X-Y — Enlarge a selected area in the X-Y region.
13 SISO Design Tool Reference • In-Y — Zoom in, Y-axis only. To do this, select In-Y, hold down your mouse’s left button, and drag vertically to create a line parallel to the Y-axis. When you release the left button, the selected area becomes the new Y-axis limits. • Out — Select Out to undo the last zoom in that you did. If you have not done any zooming, or if you have undid all your zoom enlargements, the Out menu item is grayed out. Grid Grid adds a grid to the Bode diagram.
Status Panel Status Panel The Status Panel is located at the bottom of the SISO Design Tool. It displays the most recent action you have performed and occasionally provides advice on how to use the SISO Design Tool.
13 SISO Design Tool Reference 13-36
14 LTI Viewer Reference LTI Viewer . . . . . . . . . . . . . . . . . . . . . 14-2 LTI Viewer Menu Bar . . . . . . . . . . . . . . . . 14-4 Right-Click Menus for SISO Systems . . . . . . . . 14-12 Right-Click Menus for MIMO and LTI Arrays . . . . 14-24 Status Panel . . . . . . . . . . . . . . . . . . .
14 LTI Viewer Reference LTI Viewer The LTI Viewer is a graphical user interface (GUI) that supports ten plot responses, including step, impulse, Bode, Nyquist, Nichols, zero/pole, sigma (singular values), lsim, and initial plots. The latter two are only available at the initialization of the LTI Viewer; see ltiview for more information. The LTI Viewer is configurable and can display up to six plot type and any number of models in a single viewer.
LTI Viewer Figure 14-1: The LTI Viewer and Right-Click Menus for SISO and MIMO/LTI Array Models. Click on the Plots or the Menus for Help Contents.
14 LTI Viewer Reference LTI Viewer Menu Bar Note Click on File, Edit, Window, or Help on the menu bar pictured below to get help on the menu items. This picture shows the LTI Viewer menu bar. Tasks that you can perform using the LTI Viewer menu bar include: • Importing and exporting models • Printing plot responses • Reconfiguring the Viewer (add or remove plot responses) • Displaying critical values (peak responses, etc.
LTI Viewer Menu Bar • Import and export models • Set plot preferences for all the plots generated by the Control System Toolbox • Print response plots • Close the LTI Viewer New Viewer Select this option to open a new LTI Viewer. Import Using the LTI Browser Import in the File menu opens the LTI Browser, shown below. The LTI Browser is used to import LTI models into or from the LTI Viewer workspace. To import a model • Click on the desired model in the LTI Browser List.
14 LTI Viewer Reference b Hold the Control key and click on individual variables. Hold the Shift key while clicking, to select a range. • Press the OK or Apply Button c For importing, the LTI Browser lists only the LTI models in the main MATLAB workspace. Export Using the LTI Viewer Export Window Export in the File menu opens the LTI Viewer Export window, shown below. The LTI Viewer Export window lists all the models with responses currently displayed in your LTI Viewer.
LTI Viewer Menu Bar Print to Figure Print to Figure sends a picture of the selected system to a new figure window. Note that this new figure is a MATLAB figure window and not an LTI Viewer. Close Close closes the LTI Viewer. Edit Note Click on any of the items listed in the Edit menu pictured below to get help contents.
14 LTI Viewer Reference Plot Configurations Window Plot Configuration under the Edit menu opens the Plot Configurations window. There are six possible configurations of the LTI Viewer; you can plot up to six response plots in a single viewer. Click the radio button to the upper left of the configuration you want the viewer to use. You can select among eight response types for each plot in the viewer.
LTI Viewer Menu Bar Systems The Systems menu item has two selections, Refresh and Delete. This figure shows the two options. Refresh updates imported models to reflect any changes made in the MATLAB workspace since you imported them. Delete opens the LTI Browser for System Deletion. Delete Using the LTI Browser for System Deletion Delete under Systems in the Edit menu opens the LTI Browser, shown below. To delete a model • Click on the desired model in the LTI Browser List.
14 LTI Viewer Reference a Click and drag over several variables in the list. b Hold the Control key and click on individual variables. c Hold the Shift key while clicking, to select a range. • Press the OK or Apply Button Line Styles Editor Select Line Styles under the Edit menu to open the Line Styles editor, shown below. The Line Styles editor is particularly useful when you have mutiple systems imported.
LTI Viewer Menu Bar Setting Preferences You can use the “Distinguish by” matrix to specify the line property that will vary throughout the response plots. You can group mutliple plot curves by systems, inputs, outputs, or channels (individual input/output relationships). Note that the Line Styles editor uses radio buttons, which means that you can only assign one property setting for each grouping (system, input, etc.).
14 LTI Viewer Reference Right-Click Menus for SISO Systems Note Click on items in the right-click menu pictured below for help contents. This right-click menu appears when you have a SISO system imported into your LTI Viewer. If you have a MIMO system, or an LTI array containing multiple models, there are additional menu options. See “Right-Click Menus for MIMO and LTI Arrays” for more information.
Right-Click Menus for SISO Systems Plot Type Select which plot type you want to display. The LTI Viewer shows a check to mark which plot is currently displayed. These are the available options: • Step — Step response • Impulse — Impulse response • Bode — Magnitude and phase plots • Bode Mag. — Magnitude only • Nyquist — Nyquist diagram • Nichols — Nichols chart • Sigma — Singular values plot • Pole/Zero — Pole/Zero map You cannot switch to Lsim or Initial.
14 LTI Viewer Reference Systems Use Systems to select which of the imported systems to display. Selecting a system causes a check mark to appear beside the system. To deselect a system, select it again; the menu toggles between selected and deselected. Characteristics The Characteristics menu changes for each plot response type. The next sections describe the menu for each of the eight plot types.
Right-Click Menus for SISO Systems Step Response Step plots the model’s response to a step input.
14 LTI Viewer Reference Impulse Response Impulse Response plots the model’s response to an impulse.
Right-Click Menus for SISO Systems Bode Diagram Bode plots the open-loop Bode phase and magnitude diagrams for the model. The LTI Viewer can display the following types of information in the Bode diagram: • Peak Response — The maximum value of the Bode magnitude plot over the specified region • Stability Margins — The phase and gain margins. The gain margin is defined to the gain (in dB) when the phase first crosses -180°.
14 LTI Viewer Reference Bode Magnitude Bode Magnitude plots the Bode magnitude diagram for the model. The LTI Viewer can display the Peak Response, which is the maximum value of the Bode magnitude in decibels (dB), over the specified range of the diagram.
Right-Click Menus for SISO Systems Nyquist Diagrams Nyquist plots the Nyquist diagram for the model. The LTI Viewer can display the following types of information in the Nyquist diagram: • Peak Response — The maximum value of the Nyquist diagram over the specified region • Stability Margins — The gain and phase margins for the Nyquist diagram. The gain margin is the distance from the origin to the phase crossover of the Nyquist curve. The phase crossover is where the curve meets the real axis.
14 LTI Viewer Reference Nichols Charts Nichols plots the Nichols Chart for the model. The LTI Viewer can display the following types of information in the Nichols chart: • Peak Response — The maximum value of the Nichols chart in the plotted region. • Stability Margins — The gain and phase margins for the Nichols chart.
Right-Click Menus for SISO Systems Sigma Sigma plots the singular values for the model. The LTI Viewer can display the Peak Response, which is the largest magnitude of the Sigma plot over the plotted region.
14 LTI Viewer Reference Pole/Zero Pole/Zero plots the poles and zeros of the model with ‘x’ for poles and ‘o’ for zeros. There are no Characteristics available for pole-zero plots. Grid The Grid command activates a grid appropriate to the plot in the region you select. Zoom The Zoom command zooms in and out of the plot region selected. There are four options: • In-X — Zoom in on the specified strip of the x axis. • In-Y — Zoom in on the specified strip of the y axis.
Right-Click Menus for SISO Systems Out restores the previous appearance of the plot. Note that Out is grey when you have reached the limit of zooming out. Properties Use Properties to open the Property Editor. This GUI allows you to customize labels, axes limits and units, grids and font styles, and response characteristics (e.g., rise time) for your plot. For a full description of the Property Editor, see Setting Response Plot Properties online.
14 LTI Viewer Reference Right-Click Menus for MIMO and LTI Arrays All of the menu options described in “Right-Click Menus for SISO Systems” hold when you have imported a MIMO model or LTI Array containing multiple models. Note, however, that when you have a MIMO model or LTI array displayed, the right-click menus contain additional options: Axis Grouping and I/O selector.
Right-Click Menus for MIMO and LTI Arrays Axis Grouping You can usse Axis Grouping to change the grouping of plots in your LTI Viewer. This picture shows the menu options. There are four options: • None — By default, there is no axis grouping. For example, if you display the step responses for a 3-input, 2- output system, there will be six plots in your LTI Viewer. • All — Groups all the responses into a single plot • Inputs — Groups all the responses by inputs.
14 LTI Viewer Reference default, all the I/O pairs are selected. If you click on a button, that I/O pair alone is displayed in the LTI Viewer. The other buttons automatically deselect. To select a column of inputs, click on the input name above the column. The names are U(1), U(2), and so on. The LTI Viewer displays the responses from the specified input to all the outputs. To select a row of output, click on the output name to the left of the row. The names are Y(1), Y(2), and so on.
Status Panel Status Panel The Status Panel is located at the bottom of the LTI Viewer. It contains useful information about changes you have made to the LTI Viewer.
14 LTI Viewer Reference 14-28
15 Right-Click Menus for Response Plots Right-Click Menus for SISO Systems Systems . . . . . . . . . . . . . Characteristics . . . . . . . . . . Grid . . . . . . . . . . . . . . . Zoom . . . . . . . . . . . . . . . Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4 15-4 15-4 15-5 15-6 15-6 Right-Click Menus for MIMO and LTI Arrays . . . . . 15-8 Axis Grouping . . . . . . . . . . . . . . . . . . . .
15 Right-Click Menus for Response Plots All the response plots that the Control System Toolbox creates have right-click menus available. The plots include the following: • bode • bodemag • impulse • initial • nichols • nyquist • pzmap • sigma • step Note Click on any of the items in the right-click menus, shown below, to get help on the feature. Figure 15-1: Right-Click Menus for SISO and MIMO/LTI Array Models.
- regroup the plots - Select subsets of I/O pairs 15-3
15 Right-Click Menus for Response Plots Right-Click Menus for SIXXSO Systems When you create a response plot for a SISO system, you have available a set of right-click menu options, which are desribed in the following sections. Systems Use Systems to select which of the imported systems to display. Selecting a system causes a check mark to appear beside the system. To deselect a system, select it again; the menu toggles between selected and deselected.
Right-Click Menus for SIXXSO Systems Table 15-1: Options Available from the Characteristics Menu Function Characteristics initial Peak Response nichols Peak Response nyquist Peak Response pzmap None sigma Peak Response step Peak Response Settling Time Rise Time Steady State Grid The Grid command activates a grid appropriate to the plot in the region you select.
15 Right-Click Menus for Response Plots Zoom The Zoom command zooms in and out of the plot region selected. There are four options: • In-X — Zoom in on the specified strip of the x axis. • In-Y — Zoom in on the specified strip of the y axis. • X-Y — Zoom in on the specified box region of the x and y axes. • Out — Zoom out. When you select In-X or In-Y, left-click the mouse to specify the region of the x or y axis that you want to zoom in on.
Right-Click Menus for SIXXSO Systems For a full description of the Property Editor, see Setting Response Plot Properties online.
15 Right-Click Menus for Response Plots Right-Click Menus for MIMO and LTI Arrays All of the menu options described in “Right-Click Menus for SIXXSO Systems” hold when you have generated a response plot for a MIMO model or an LTI Array. Note, however, that when you have a MIMO model or LTI array displayed, the right-click menus contain additional options: Axis Grouping and I/O selector. These features allow you to quickly reshuffle multiple plots in a single window.
Right-Click Menus for MIMO and LTI Arrays • None — By default, there is no axis grouping. For example, if you display the step responses for a 3-input, 2- output system, there will be six plots in your window. • All — Groups all the responses into a single plot • Inputs — Groups all the responses by inputs. For example, for a 3-input, 2-output system, selecting Inputs reconfigures the viewer so that there are 3 plots. Each plot contains two curves. • Outputs — Groups all the responses by outputs.
15 Right-Click Menus for Response Plots 15-10
16 Function Reference Functions by Category . . . . . . . . . . . . . . .
16 Function Reference This chapter contains detailed descriptions of all Control System Toolbox functions. It begins with a list of functions grouped by subject area and continues with the reference entries in alphabetical order. Information is also available through the online Help facility.
Functions by Category Functions by Category Table 16-1: LTI Models Function Name Description drss Generate random discrete state-space model dss Create descriptor state-space model filt Create discrete filter with DSP convention frd Create a frequency response data (FRD) model frdata Retrieve data from an FRD model get Query LTI model properties rss Generate random continuous state-space model set Set LTI model properties ss Create state-space model ssdata, dssdata Retrieve state-space
16 Function Reference Table 16-2: Model Characteristics Function Name Description class Display model type ('tf', 'zpk', 'ss', or 'frd') hasdelay Test true if LTI model has any type of delay isa Test true if LTI model is of specified type isct Test true for continuous-time models isdt Test true for discrete-time models isempty Test true for empty LTI models isproper Test true for proper LTI models issiso Test true for SISO models ndims Display the number of model/array dimensions size
Functions by Category Table 16-3: Model Conversion (Continued) Function Name Description pade Compute the Padé approximation of delays reshape Change the shape of an LTI array residue Provide partial fraction expansion ss Convert to a state space model tf Convert to a transfer function model zpk Convert to a zero-pole-gain model Table 16-4: Model Order Reduction Function Name Description balreal Calculate an I/O balanced realization minreal Calculate minimal realization or eliminate pole
16 Function Reference Table 16-5: State-Space Realizations (Continued) Function Name Description obsv Observability matrix obsvf Observability staircase form ss2ss State coordinate transformation. ssbal Diagonal balancing of state-space realizations.
Functions by Category Table 16-7: Model Interconnections Function Name Description append Append models in a block diagonal configuration augstate Augment output by appending states connect Connect the subsystems of a block-diagonal model according to an interconnection scheme of your choice feedback Calculate the feedback connection of models lft Form the LFT interconnection (star product) ord2 Generate second-order model parallel Create a generalized parallel connection series Create a g
16 Function Reference Table 16-9: Time Delays Function Name Description delay2z Convert delays in discrete-time models or FRD models pade Compute the Padé approximation of delays totaldelay Provide the aggregate delay for an LTI model Table 16-10: Frequency Response 16-8 Function Name Description allmargin Calculate all crossover frequencies and associated gain, phase, and delay margins bode Calculate and plot Bode response bodemag Calculate and plot Bode magnitude only evalfr Evaluate
Functions by Category Table 16-10: Frequency Response (Continued) Function Name Description nyquist Calculate Nyquist plot sigma Calculate singular value plot Table 16-11: SISO Feedback Design Function Name Description allmargin Calculate all crossover frequencies and associated gain, phase, and delay margins margin Calculate gain and phase margins rlocus Calculate and plot root locus sisotool Open the SISO Design Tool Table 16-12: Pole Placement Function Name Description acker Calculate
16 Function Reference Table 16-13: LQG Design (Continued) Function Name Description lqry Calculate the LQ-optimal gain with output weighting lqrd Calculate the discrete LQ gain for continuous models kalman Calculate the Kalman estimator kalmd Calculate the discrete Kalman estimator for continuous models lqgreg Form LQG regulator given LQ gain and Kalman filter Table 16-14: Equation Solvers Function Name Description care Solve continuous-time algebraic Riccati equations dare Solve discrete
acker Purpose 16acker Pole placement design for single-input systems Syntax k = acker(A,b,p) Description Given the single-input system x· = Ax + bu and a vector p of desired closed-loop pole locations, acker (A,b,p)uses Ackermann’s formula [1] to calculate a gain vector k such that the state feedback u = – kx places the closed-loop poles at the locations p. In other words, the eigenvalues of A – bk match the entries of p (up to ordering).
allmargin Purpose 16allmargin Compute all crossover frequencies and corresponding stability margins Syntax S = allmargin(sys) Description allmargin computes the gain, phase, and delay margins and the corresponding crossover frequencies of the SISO open-loop model sys. allmargin is applicable to any SISO model, including models with delays.
append Purpose 16append Group LTI models by appending their inputs and outputs Syntax sys = append(sys1,sys2,...,sysN) Description append appends the inputs and outputs of the LTI models sys1,...,sysN to form the augmented model sys depicted below. u1 sys1 y1 u2 sys2 y2 : : uN yN sysN sys For systems with transfer functions H 1 ( s ) ,..., H N ( s ) , the resulting system sys has the block-diagonal transfer function H1 ( s ) 0 : 0 0 .. 0 H2( s ) . : . .. .
append x· 1 A1 0 x1 B 0 u1 = + 1 ·x 0 A2 x2 0 B2 u2 2 y1 y2 Arguments = C1 0 x1 0 C2 x2 + D1 0 u1 0 D2 u2 The input arguments sys1,..., sysN can be LTI models of any type. Regular matrices are also accepted as a representation of static gains, but there should be at least one LTI object in the input list. The LTI models should be either all continuous, or all discrete with the same sample time.
append y2 y3 0 0 0 3.00000 y1 y2 y3 u1 0 0 0 u2 0 10.00000 0 d = u3 0 0 4.00000 Continuous-time system.
augstate Purpose 16augstate Append the state vector to the output vector Syntax asys = augstate(sys) Description Given a state-space model sys with equations x· = Ax + Bu y = Cx + Du (or their discrete-time counterpart), augstate appends the states x to the outputs y to form the model x· = Ax + Bu y = C x+ D u 0 x I This command prepares the plant so that you can use the feedback command to close the loop on a full-state feedback u = – K x .
balreal Purpose 16balreal Input/output balancing of state-space realizations Syntax sysb = balreal(sys) [sysb,g,T,Ti] = balreal(sys) Description sysb = balreal(sys) produces a balanced realization sysb of the LTI model sys with equal and diagonal controllability and observability grammians (see gram for a definition of grammian). balreal handles both continuous and discrete systems. If sys is not a state-space model, it is first and automatically converted to state space using ss.
balreal 1.0062e-01 6.8039e-05 1.0055e-05 which indicates that the last two states of sysb are weakly coupled to the input and output. You can then delete these states by sysr = modred(sysb,[2 3],'del') to obtain the following first-order approximation of the original system. zpk(sysr) Zero/pole/gain: 1.0001 -------(s+4.97) Compare the Bode responses of the original and reduced-order models.
balreal bode(sys,'-',sysr,'x') Bode Diagrams −10 −20 Phase (deg); Magnitude (dB) −30 −40 −50 0 −20 −40 −60 −80 −100 0 10 1 10 2 10 Frequency (rad/sec) Algorithm Consider the model x· = Ax + Bu y = Cx + Du with controllability and observability grammians W c and W o .
balreal T W c = TW c T , Wo = T –T Wo T –1 The function balreal computes a particular similarity transformation T such that W c = W o = diag ( g ) See [1,2] for details on the algorithm. Limitations The LTI model sys must be stable. In addition, controllability and observability are required for state-space models. See Also gram minreal modred References [1] Laub, A.J., M.T. Heath, C.C. Paige, and R.C.
bode Purpose Syntax 16bode Compute the Bode frequency response of LTI models bode(sys) bode(sys,w) bode(sys1,sys2,...,sysN) bode(sys1,sys2,...,sysN,w) bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [mag,phase,w] = bode(sys) Description bode computes the magnitude and phase of the frequency response of LTI models. When invoked without left-hand arguments, bode produces a Bode plot on the screen. The magnitude is plotted in decibels (dB), and the phase in degrees.
bode uses red dashed lines for the first system sys1 and green 'x' markers for the second system sys2. When invoked with left-hand arguments [mag,phase,w] = bode(sys) [mag,phase] = bode(sys,w) return the magnitude and phase (in degrees) of the frequency response at the frequencies w (in rad/sec). The outputs mag and phase are 3-D arrays with the frequency as the last dimension (see “Arguments” below for details).
bode 2 s + 0.1s + 7.5 H ( s ) = --------------------------------------------4 3 2 s + 0.12s + 9s by typing g = tf([1 0.1 7.5],[1 0.12 9 0 0]); bode(g) To plot the response on a wider frequency range, for example, from 0.1 to 100 rad/sec, type bode(g,{0.1 , 100}) You can also discretize this system using zero-order hold and the sample time T s = 0.5 second, and compare the continuous and discretized responses by typing gd = c2d(g,0.
bode bode(g,'r',gd,'b--') Algorithm For continuous-time systems, bode computes the frequency response by evaluating the transfer function H ( s ) on the imaginary axis s = jω . Only positive frequencies ω are considered. For state-space models, the frequency –1 response is D + C ( jω – A ) B , ω≥0 When numerically safe, A is diagonalized for maximum speed.
bode where T s is the sample time. ω N is called the Nyquist frequency. The equivalent “continuous-time frequency” ω is then used as the x -axis variable. Because H( e jωT s ) is periodic with period 2ω N , bode plots the response only up to the Nyquist frequency ω N . If the sample time is unspecified, the default value T s = 1 is assumed.
bodemag Purpose Syntax 16bodemag Compute the Bode magnitude response of LTI models bodemag(sys) bodemag(sys,{wmin,wmax}) bodemag(sys,w) bodemag(sys1,sys2,...,sysN,w) bodemag(sys1,'PlotStyle1',...,sysN,'PlotStyleN') Description bodemag(sys) plots the magnitude of the frequency response of the LTI model SYS (Bode plot without the phase diagram). The frequency range and number of points are chosen automatically.
c2d Purpose 16c2d Discretize continuous-time systems Syntax sysd = c2d(sys,Ts) sysd = c2d(sys,Ts,method) [sysd,G] = c2d(sys,Ts,method) Description sysd = c2d(sys,Ts) discretizes the continuous-time LTI model sys using zero-order hold on the inputs and a sample time of Ts seconds. sysd = c2d(sys,Ts,method) gives access to alternative discretization schemes. The string method selects the discretization method among the following: 'zoh' Zero-order hold.
c2d Example Consider the system s–1 H ( s ) = ---------------------------2 s + 4s + 5 with input delay T d = 0.35 second. To discretize this system using the triangle approximation with sample time T s = 0.1 second, type H = tf([1 -1],[1 4 5],'inputdelay',0.35) Transfer function: s - 1 exp(-0.35*s) * ------------s^2 + 4 s + 5 Hd = c2d(H,0.1,'foh') Transfer function: 0.0115 z^3 + 0.0456 z^2 - 0.0562 z - 0.009104 --------------------------------------------z^6 - 1.629 z^5 + 0.6703 z^4 Sampling time: 0.
c2d step(H,'-',Hd,'--') See Also d2c d2d References [1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of Dynamic Systems, Second Edition, Addison-Wesley, 1990.
canon Purpose 16canon Compute canonical state-space realizations Syntax csys = canon(sys,'type') [csys,T] = canon(sys,'type') Description canon computes a canonical state-space model for the continuous or discrete LTI system sys. Two types of canonical forms are supported.
canon For state-space models sys, [csys,T] = canon(a,b,c,d,'type') also returns the state coordinate transformation T relating the original state vector x and the canonical state vector x c . x c = Tx This syntax returns T=[] when sys is not a state-space model. Algorithm Transfer functions or zero-pole-gain models are first converted to state space using ss. The transformation to modal form uses the matrix P of eigenvectors of the A matrix.
care Purpose Syntax 16care Solve continuous-time algebraic Riccati equations (CARE) [X,L,G,rr] = care(A,B,Q) [X,L,G,rr] = care(A,B,Q,R,S,E) [X,L,G,report] = care(A,B,Q,...,'report') [X1,X2,L,report] = care(A,B,Q,...,'implicit') Description [X,L,G,rr] = care(A,B,Q) computes the unique solution X of the algebraic Riccati equation T T Ric ( X ) = A X + XA – XBB X + Q = 0 T such that A – BB X has all its eigenvalues in the open left-half plane.
care • The relative residual rr defined above when the solution exists (success) Alternatively, [X1,X2,L,report] = care(A,B,Q,...,'implicit') also turns off error messages but now returns X in implicit form. –1 X = X2 X 1 Note that this syntax returns report = 0 when successful.
care -3.4495 1.4495 -3.5026 -1.4370 Finally, note that the variable l contains the closed-loop eigenvalues eig(a-b*g). l l = -3.5026 -1.
care have no eigenvalue on the imaginary axis. Sufficient conditions for this to hold are ( Q, A ) detectable when S = 0 and R > 0 , or Q S T >0 S R See Also dare lyap References [1] Arnold, W.F., III and A.J. Laub, “Generalized Eigenproblem Algorithms and Software for Algebraic Riccati Equations,” Proc. IEEE, 72 (1984), pp. 1746–1754.
chgunits Purpose 16chgunits Convert the frequency units of an FRD model Syntax sys = chgunits(sys,units) Description sys = chgunits(sys,units) converts the units of the frequency points stored in an FRD model, sys to units, where units is either of the strings 'Hz' or 'rad/s'. This operation changes the assigned frequencies by applying the appropriate (2*pi) scaling factor, and the 'Units' property is updated. If the 'Units' field already matches units, no conversion is made.
connect Purpose 16connect Derive state-space model from block diagram description Syntax sysc = connect(sys,Q,inputs,outputs) Description Complex dynamical systems are often given in block diagram form. For systems of even moderate complexity, it can be quite difficult to find the state-space model required in order to bring certain analysis and design tools into use. Starting with a block diagram description, you can use append and connect to construct a state-space model of the system.
connect inputs = [1 2 15]; outputs = [2 7]; The final model sysc has these particular inputs and outputs. Since it is easy to make a mistake entering all the data required for a large model, be sure to verify your model in as many ways as you can. Here are some suggestions: • Make sure the poles of the unconnected model sys match the poles of the various blocks in the diagram. • Check that the final poles and DC gains are reasonable.
connect -13.5009 18.0745]; D = [-.5476 -.1410 -.6459 .2958 ]; Define the three blocks as individual LTI models. sys1 = tf(10,[1 5],'inputname','uc') sys2 = ss(A,B,C,D,'inputname',{'u1' 'u2'},... 'outputname',{'y1' 'y2'}) sys3 = zpk(-1,-2,2) Next append these blocks to form the unconnected model sys. sys = append(sys1,sys2,sys3) This produces the block-diagonal model sys a = x1 x2 x3 x4 x1 -5 0 0 0 x2 0 -9.0201 -1.6943 0 x3 0 17.779 3.2138 0 x4 0 0 0 -2 x1 x2 x3 x4 uc 4 0 0 0 u1 0 -0.5112 -0.
connect d = uc 0 0 0 0 ? y1 y2 ? u1 0 -0.5476 -0.6459 0 u2 0 -0.141 0.2958 0 ? 0 0 0 2 Continuous-time system. Note that the ordering of the inputs and outputs is the same as the block ordering you chose. Unnamed inputs or outputs are denoted by ?. To derive the overall block diagram model from sys, specify the interconnections and the external inputs and outputs. You need to connect outputs 1 and 4 into input 3 (u2), and output 3 (y2) into input 4.
connect x1 x2 x3 x4 uc 4 0 0 0 y1 y2 x1 -0.22148 0.46463 y1 y2 uc 0 0 u1 0 -0.076001 -1.5011 -0.57391 c = x2 -5.6818 -8.4826 x3 5.6568 11.356 x4 -0.12529 0.26283 d = u1 -0.66204 -0.40582 Continuous-time system. Note that the inputs and outputs are as desired. See Also append feedback minreal parallel series References [1] Edwards, J.W., “A Fortran Program for the Analysis of Linear Continuous and Sampled-Data Systems,” NASA Report TM X56038, Dryden Research Center, 1976.
covar Purpose 16covar Output and state covariance of a system driven by white noise Syntax [P,Q] = covar(sys,W) Description covar calculates the stationary covariance of the output y of an LTI model sys driven by Gaussian white noise inputs w . This function handles both continuous- and discrete-time cases.
covar p = 30.3167 You can compare this output of covar to simulation results. randn('seed',0) w = sqrt(5)∗randn(1,1000); % 1000 samples % Simulate response to w with LSIM: y = lsim(sys,w); % Compute covariance of y values psim = sum(y .∗ y)/length(w); This yields psim = 32.6269 The two covariance values p and psim do not agree perfectly due to the finite simulation horizon. Algorithm Transfer functions and zero-pole-gain models are first converted to state space with ss.
covar Note that P is well defined for nonzero D in the discrete case. Limitations The state and output covariances are defined for stable systems only. For continuous systems, the output response covariance P is finite only when the D matrix is zero (strictly proper system). See Also dlyap lyap References [1] Bryson, A.E. and Y.C. Ho, Applied Optimal Control, Hemisphere Publishing, 1975, pp. 458-459.
ctrb Purpose 16ctrb Form the controllability matrix Syntax Co = ctrb(A,B) Co = ctrb(sys) Description ctrb computes the controllability matrix for state-space systems. For an n-by-n matrix A and an n-by-m matrix B, ctrb(A,B) returns the controllability matrix Co = B AB A2 B … A n – 1 B (16-1) where Co has n rows and nm columns. Co = ctrb(sys) calculates the controllability matrix of the state-space LTI object sys. This syntax is equivalent to executing Co = ctrb(sys.A,sys.
ctrb Limitations Estimating the rank of the controllability matrix is ill-conditioned; that is, it is very sensitive to round-off errors and errors in the data. An indication of this can be seen from this simple example. A = 1 δ , 0 1 B = 1 δ This pair is controllable if δ ≠ 0 but if δ < eps , where eps is the relative machine precision. ctrb(A,B) returns 1 1 B AB = δ δ which is not full rank. For cases like these, it is better to determine the controllability of a system using ctrbf.
ctrbf Purpose Syntax Description 16ctrbf Compute the controllability staircase form [Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C) [Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C,tol) If the controllability matrix of ( A, B ) has rank r ≤ n , where n is the size of A , then there exists a similarity transformation such that T A = TAT , B = TB, C = CT T where T is unitary, and the transformed system has a staircase form, in which the uncontrollable modes, if there are any, are in the upper left corner.
ctrbf B = 1 1 -1 -1 1 0 0 1 C = and locate the uncontrollable mode. [Abar,Bbar,Cbar,T,k]=ctrbf(A,B,C) Abar = -3.0000 -3.0000 0 2.0000 Bbar = 0.0000 1.4142 0.0000 -1.4142 Cbar = -0.7071 0.7071 0.7071 0.7071 T = -0.7071 0.7071 k = 1 0 0.7071 0.7071 The decomposed system Abar shows an uncontrollable mode located at –3 and a controllable mode located at 2. Algorithm ctrbf is an M-file that implements the Staircase Algorithm of [1]. See Also ctrb minreal References [1] Rosenbrock, M.M.
d2c Purpose 16d2c Convert discrete-time LTI models to continuous time Syntax sysc = d2c(sysd) sysc = d2c(sysd,method) Description d2c converts LTI models from discrete to continuous time using one of the following conversion methods: 'zoh' Zero-order hold on the inputs. The control inputs are assumed piecewise constant over the sampling period. 'tustin' Bilinear (Tustin) approximation to the derivative. 'prewarp' Tustin approximation with frequency prewarping.
d2c c2d(Hc,0.1,'tustin') gives back the original H ( z ) . Algorithm The 'zoh' conversion is performed in state space and relies on the matrix logarithm (see logm in Using MATLAB). Limitations The Tustin approximation is not defined for systems with poles at z = – 1 and is ill-conditioned for systems with poles near z = – 1 . The zero-order hold method cannot handle systems with poles at z = 0 . In addition, the 'zoh' conversion increases the model order for systems with negative real poles, [2].
d2c c2d(Hc,Ts) yielding Zero/pole/gain: (z+0.5) (z+0.2) ------------------------(z+0.5)^2 (z^2 + z + 0.4) Sampling time: 0.1 This discrete model coincides with H ( z ) after canceling the pole/zero pair at z = – 0.5 . See Also c2d d2d logm References [1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of Dynamic Systems, Second Edition, Addison-Wesley, 1990. Continuous- to discrete-time conversion Resampling of discrete models Matrix logarithm [2] Kollár, I., G.F. Franklin, and R.
d2d Purpose 16d2d Resample discrete-time LTI models or add input delays Syntax sys1 = d2d(sys,Ts) Description sys1 = d2d(sys,Ts) resamples the discrete-time LTI model sys to produce an equivalent discrete-time model sys1 with the new sample time Ts (in seconds). The resampling assumes zero-order hold on the inputs and is equivalent to consecutive d2c and c2d conversions. sys1 = c2d(d2c(sys),Ts) Example Consider the zero-pole-gain model z – 0.7 H ( z ) = ----------------z – 0.5 with sample time 0.
damp Purpose 16damp Compute damping factors and natural frequencies Syntax [Wn,Z] = damp(sys) [Wn,Z,P] = damp(sys) Description damp calculates the damping factor and natural frequencies of the poles of an LTI model sys. When invoked without lefthand arguments, a table of the eigenvalues in increasing frequency, along with their damping factors and natural frequencies, is displayed on the screen.
damp damp(H) and MATLAB returns Eigenvalue Damping -1.00e+000 + 1.41e+000i -1.00e+000 - 1.41e+000i See Also 16-54 eig esort,dsort pole pzmap zero Freq. (rad/s) 5.77e-001 5.77e-001 1.73e+000 1.
dare Purpose Syntax 16dare Solve discrete-time algebraic Riccati equations (DARE) [X,L,G,rr] = dare(A,B,Q,R) [X,L,G,rr] = dare(A,B,Q,R,S,E) [X,L,G,report] = dare(A,B,Q,...,'report') [X1,X2,L,report] = dare(A,B,Q,...
dare and L = eig(A-B*G,E). Two additional syntaxes are provided to help develop applications such as H ∞ -optimal control design. [X,L,G,report] = dare(A,B,Q,...,'report') turns off the error messages when the solution X fails to exist and returns a failure report instead.
dare References [1] Arnold, W.F., III and A.J. Laub, “Generalized Eigenproblem Algorithms and Software for Algebraic Riccati Equations,” Proc. IEEE, 72 (1984), pp. 1746–1754.
dcgain Purpose 16dcgain Compute low frequency (DC) gain of LTI system Syntax k = dcgain(sys) Description k = dcgain(sys) computes the DC gain k of the LTI model sys. Continuous Time The continuous-time DC gain is the transfer function value at the frequency s = 0 . For state-space models with matrices ( A, B, C, D ) , this value is –1 K = D – CA B Discrete Time The discrete-time DC gain is the transfer function value at z = 1 .
delay2z Purpose 16delay2z Replace delays of discrete-time TF, SS, or ZPK models by poles at z=0, or replace delays of FRD models by a phase shift Syntax sys = delay2z(sys) Description sys = delay2z(sys) maps all time delays to poles at z=0 for discrete-time TF, ZPK, or SS models sys. Specifically, a delay of k sampling periods is replaced by (1/z)^k in the transfer function corresponding to the model.
dlqr Purpose Syntax Description 16dlqr Design linear-quadratic (LQ) state-feedback regulator for discrete-time plant [K,S,e] = dlqr(a,b,Q,R) [K,S,e] = dlqr(a,b,Q,R,N) [K,S,e] = dlqr(a,b,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u [ n ] = – Kx [ n ] minimizes the quadratic cost function ∞ T å J(u) = T T ( x [ n ] Qx [ n ] + u [ n ] Ru [ n ] + 2x [ n ] Nu [ n ] ) n=1 for the discrete-time state-space mode l x [ n + 1 ] = Ax [ n ] + Bu [ n ] The default value N=0 i
dlqr lqr lqrd lqry State-feedback LQ regulator for continuous plant Discrete LQ regulator for continuous plant State-feedback LQ regulator with output weighting 16-61
dlyap Purpose 16dlyap Solve discrete-time Lyapunov equations Syntax X = dlyap(A,Q) Description dlyap solves the discrete-time Lyapunov equation T A XA – X + Q = 0 where A and Q are n -by- n matrices. The solution X is symmetric when Q is symmetric, and positive definite when Q is positive definite and A has all its eigenvalues inside the unit disk. Diagnostics The discrete-time Lyapunov equation has a (unique) solution if the eigenvalues α 1, α 2, ...
drss Purpose 16drss Generate stable random discrete test models Syntax sys sys sys sys Description sys = drss(n) produces a random n-th order stable model with one input and one output, and returns the model in the state-space object sys. = = = = drss(n) drss(n,p) drss(n,p,m) drss(n,p,m,s1,...sn) drss(n,p) produces a random n-th order stable model with one input and p outputs. drss(n,m,p) generates a random n-th order stable model with m inputs and p outputs. drss(n,p,m,s1,...
drss c = y1 y2 x1 0.22595 0 x2 0.76037 0 y1 y2 u1 0 0.78333 u2 0.68085 0.46110 x3 0 0 d = Sampling time: unspecified Discrete-time system.
dsort Purpose 16dsort Sort discrete-time poles by magnitude Syntax s = dsort(p) [s,ndx] = dsort(p) Description dsort sorts the discrete-time poles contained in the vector p in descending order by magnitude. Unstable poles appear first. When called with one lefthand argument, dsort returns the sorted poles in s. [s,ndx] = dsort(p) also returns the vector ndx containing the indices used in the sort. Example Sort the following discrete poles. p = -0.2410 + 0.5573i -0.2410 - 0.5573i 0.1503 -0.
dss Purpose Syntax 16dss Specify descriptor state-space models sys = dss(a,b,c,d,e) sys = dss(a,b,c,d,e,Ts) sys = dss(a,b,c,d,e,ltisys) sys = dss(a,b,c,d,e,'Property1',Value1,...,'PropertyN',ValueN) sys = dss(a,b,c,d,e,Ts,'Property1',Value1,...,'PropertyN',ValueN) Description sys = dss(a,b,c,d,e) creates the continuous-time descriptor state-space model Ex· = Ax + Bu y = Cx + Du The E matrix must be nonsingular. The output sys is an SS model storing the model data (see “LTI Objects” on page 2-3).
dss sys = dss(1,2,3,4,5,'td',0.1,'inputname','voltage',... 'notes','Just an example') creates the model 5x· = x + 2u y = 3x + 4u with a 0.1 second input delay. The input is labeled 'voltage', and a note is attached to tell you that this is just an example.
dssdata Purpose 16dssdata Quick access to descriptor state-space data Syntax [a,b,c,d,e] = dssdata(sys) [a,b,c,d,e,Ts] = dssdata(sys) Description [a,b,c,d,e] = dssdata(sys) extracts the descriptor matrix data ( A, B, C, D, E ) from the state-space model sys. If sys is a transfer function or zero-pole-gain model, it is first converted to state space. Note that dssdata is then equivalent to ssdata because it always returns E = I . [a,b,c,d,e,Ts] = dssdata(sys) also returns the sample time Ts.
esort Purpose 16esort Sort continuous-time poles by real part Syntax s = esort(p) [s,ndx] = esort(p) Description esort sorts the continuous-time poles contained in the vector p by real part. Unstable eigenvalues appear first and the remaining poles are ordered by decreasing real parts. When called with one left-hand argument, s = esort(p) returns the sorted eigenvalues in s. [s,ndx] = esort(p) returns the additional argument ndx, a vector containing the indices used in the sort.
esort zero 16-70 Compute (transmission) zeros
estim Purpose 16estim Form state estimator given estimator gain Syntax est = estim(sys,L) est = estim(sys,L,sensors,known) Description est = estim(sys,L) produces a state/output estimator est given the plant state-space model sys and the estimator gain L. All inputs w of sys are assumed stochastic (process and/or measurement noise), and all outputs y are measured. The estimator est is returned in state-space form (SS object).
estim · x̂ = Ax̂ + B 2 u + L ( y – C 2 x̂ – D 22 u ) ŷ = C 2 x̂ + D 22 u x̂ I 0 u (known) ŷ est y (sensors) x̂ estim handles both continuous- and discrete-time cases. You can use the functions place (pole placement) or kalman (Kalman filtering) to design an adequate estimator gain L . Note that the estimator poles (eigenvalues of A – LC ) should be faster than the plant dynamics (eigenvalues of A ) to ensure accurate estimation.
evalfr Purpose 16evalfr Evaluate frequency response at a single (complex) frequency Syntax frsp = evalfr(sys,f) Description frsp = evalfr(sys,f) evaluates the transfer function of the TF, SS, or ZPK model sys at the complex number f. For state-space models with data ( A, B, C, D ) , the result is –1 H ( f ) = D + C ( fI – A ) B evalfr is a simplified version of freqresp meant for quick evaluation of the response at a single point.
feedback Purpose Syntax Description 16feedback Feedback connection of two LTI models sys = feedback(sys1,sys2) sys = feedback(sys1,sys2,sign) sys = feedback(sys1,sys2,feedin,feedout,sign) sys = feedback(sys1,sys2) returns an LTI model sys for the negative feedback interconnection. + u sys1 y - sys2 The closed-loop model sys has u as input vector and y as output vector. The LTI models sys1 and sys2 must be both continuous or both discrete with identical sample times.
feedback computes a closed-loop model sys for the more general feedback loop. v z + sys1 u y - sys2 sys The vector feedin contains indices into the input vector of sys1 and specifies which inputs u are involved in the feedback loop. Similarly, feedout specifies which outputs y of sys1 are used for feedback. The resulting LTI model sys has the same inputs and outputs as sys1 (with their order preserved).
feedback Examples Example 1 + torque G velocity - H To connect the plant 2 2s + 5s + 1 G ( s ) = ------------------------------2 s + 2s + 3 with the controller 5(s + 2) H ( s ) = -------------------s + 10 using negative feedback, type G = tf([2 5 1],[1 2 3],'inputname','torque',... 'outputname','velocity'); H = zpk(-2,-10,5) Cloop = feedback(G,H) and MATLAB returns Zero/pole/gain from input "torque" to output "velocity": 0.18182 (s+10) (s+2.281) (s+0.2192) ----------------------------------(s+3.
feedback Example 2 Consider a state-space plant P with five inputs and four outputs and a state-space feedback controller K with three inputs and two outputs.
filt Purpose Syntax 16filt Specify discrete transfer functions in DSP format sys = filt(num,den) sys = filt(num,den,Ts) sys = filt(M) sys = filt(num,den,'Property1',Value1,...,'PropertyN',ValueN) sys = filt(num,den,Ts,'Property1',Value1,...
filt MIMO transfer functions are regarded as arrays of SISO transfer functions (one per I/O channel), each of which is characterized by its numerator and denominator. The input arguments num and den are then cell arrays of row vectors such that: • num and den have as many rows as outputs and as many columns as inputs. • Their ( i, j ) entries num{i,j} and den{i,j} specify the numerator and denominator of the transfer function from input j to output i.
frd Purpose Syntax 16frd Create a frequency response data (FRD) object or convert another model type to an FRD model sys sys sys sys = = = = frd(response,frequency) frd(response,frequency,Ts) frd frd(response,frequency,ltisys) sysfrd = frd(sys,frequency) sysfrd = frd(sys,frequency,'Units',units) Description sys = frd(response,frequency) creates an FRD model sys from the frequency response data stored in the multidimensional array response.
frd sysfrd = frd(sys,frequency,'Units',units)converts an FRD model from a TF, SS, or ZPK model while specifying the units for frequency to be units ('rad/s' or 'Hz'). Arguments When you specify a SISO or MIMO FRD model, or an array of FRD models, the input argument frequency is always a vector of length Nf, where Nf is the number of frequency data points in the FRD. The specification of the input argument response is summarized in the following table.
frd tf zpk 16-82 Create transfer functions Create zero-pole-gain models
frdata Purpose 16frdata Quick access to data for a frequency response data object Syntax [response,freq] = frdata(sys) [response,freq,Ts] = frdata(sys) [response,freq] = frdata(sys,'v') Description [response,freq] = frdata(sys) returns the response data and frequency samples of the FRD model sys. For an FRD model with Ny outputs and Nu inputs at Nf frequencies: • response is an Ny-by-Nu-by-Nf multidimensional array where the (i,j) entry specifies the response from input j to output i.
frdata 2.4359 - 4.
freqresp Purpose 16freqresp Compute frequency response over grid of frequencies Syntax H = freqresp(sys,w) Description H = freqresp(sys,w) computes the frequency response of the LTI model sys at the real frequency points specified by the vector w. The frequencies must be in radians/sec. For single LTI Models, freqresp(sys,w) returns a 3-D array H with the frequency as the last dimension (see “Arguments” below). For LTI arrays of size [Ny Nu S1 ... Sn], freqresp(sys,w) returns a [Ny-by-Nu-by-S1-by-..
freqresp P( s) = 0 1 -----------s+1 s–1 -----------s+2 1 at the frequencies ω = 1, 10, 100 . Type w = [1 10 100] H = freqresp(P,w) H(:,:,1) = 0 -0.2000+ 0.6000i 0.5000- 0.5000i 1.0000 H(:,:,2) = 0 0.9423+ 0.2885i 0.0099- 0.0990i 1.0000 H(:,:,3) = 0 0.9994+ 0.0300i 0.0001- 0.0100i 1.
freqresp Algorithm For transfer functions or zero-pole-gain models, freqresp evaluates the numerator(s) and denominator(s) at the specified frequency points. For continuous-time state-space models ( A, B, C, D ) , the frequency response is –1 D + C ( jω – A ) B , ω = ω 1, ..., ω N For efficiency, A is reduced to upper Hessenberg form and the linear equation ( jω – A )X = B is solved at each frequency point, taking advantage of the Hessenberg structure.
gensig Purpose 16gensig Generate test input signals for lsim Syntax [u,t] = gensig(type,tau) [u,t] = gensig(type,tau,Tf,Ts) Description [u,t] = gensig(type,tau) generates a scalar signal u of class type and with period tau (in seconds). The following types of signals are available. type = 'sin' Sine wave. type = 'square' Square wave. type = 'pulse' Periodic pulse. gensig returns a vector t of time samples and the vector u of signal values at these samples.
gensig axis([0 30 -1 2]) 2 1.5 1 0.5 0 −0.
get Purpose 16get Access/query LTI property values Syntax Value = get(sys,'PropertyName') get(sys) Struct = get(sys) Description Value = get(sys,'PropertyName') returns the current value of the property PropertyName of the LTI model sys. The string 'PropertyName' can be the full property name (for example, 'UserData') or any unambiguous case-insensitive abbreviation (for example, 'user').
get Notes = {} UserData = 'hello' or query only about the numerator and sample time values by get(h,'num') ans = [1x2 double] and get(h,'ts') ans = 0.1000 Because the numerator data (num property) is always stored as a cell array, the first command evaluates to a cell array containing the row vector [0 1]. Remark An alternative to the syntax Value = get(sys,'PropertyName') is the structure-like referencing Value = sys.PropertyName For example, sys.Ts sys.a sys.
gram Purpose 16gram Compute controllability and observability state-space models:descriptor;state-space models:quick data retrievalgrammians Syntax Wc = gram(sys,'c') Wo = gram(sys,'o') Description gram calculates controllability and observability grammians. You can use grammians to study the controllability and observability properties of state-space models and for model reduction [1,2].
gram to compute the grammians of a continuous or discrete system. The LTI model sys must be in state-space form. Algorithm The controllability grammian W c is obtained by solving the continuous-time Lyapunov equation T AW c + W c A + BB T = 0 or its discrete-time counterpart T AW c A – W c + BB T = 0 Similarly, the observability grammian W o solves the Lyapunov equation T T A Wo + W o A + C C = 0 in continuous time, and the Lyapunov equation T T A Wo A – Wo + C C = 0 in discrete time.
hasdelay Purpose 16hasdelay Test if an LTI model has time delays Syntax hasdelay(sys) Description hasdelay(sys) returns 1 (true) if the LTI model sys has input delays, output delays, or I/O delays, and 0 (false) otherwise.
impulse Purpose Syntax 16impulse Compute the impulse response of LTI models impulse(sys) impulse(sys,t) impulse(sys1,sys2,...,sysN) impulse(sys1,sys2,...,sysN,t) impulse(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [y,t,x] = impulse(sys) Description impulse calculates the unit impulse response of a linear system. The impulse response is the response to a Dirac input δ ( t ) for continuous-time systems and to a unit pulse at t = 0 for discrete-time systems.
impulse As with bode or plot, you can specify a particular color, linestyle, and/or marker for each system, for example, impulse(sys1,'y:',sys2,'g--') See “Plotting and Comparing Multiple Systems” on and the bode entry in this chapter for more details.
impulse sys = ss(a,b,c,0); impulse(sys) The left plot shows the impulse response of the first input channel, and the right plot shows the impulse response of the second input channel. You can store the impulse response data in MATLAB arrays by [y,t] = impulse(sys) Because this system has two inputs, y is a 3-D array with dimensions size(y) ans = 101 1 2 (the first dimension is the length of t).
impulse Algorithm Continuous-time models are first converted to state space. The impulse response of a single-input state-space model x· = Ax + bu y = Cx is equivalent to the following unforced response with initial state b . x· = Ax , x( 0 ) = b y = Cx To simulate this response, the system is discretized using zero-order hold on the inputs. The sampling period is chosen automatically based on the system dynamics, except when a time vector t = 0:dt:Tf is supplied (dt is then used as sampling period).
initial Purpose Syntax 16initial Compute the initial condition response of state-space models initial(sys,x0) initial(sys,x0,t) initial(sys1,sys2,...,sysN,x0) initial(sys1,sys2,...,sysN,x0,t) initial(sys1,'PlotStyle1',...,sysN,'PlotStyleN',x0) [y,t,x] = initial(sys,x0) Description initial calculates the unforced response of a state-space model with an initial condition on the states. x· = Ax , x ( 0 ) = x0 y = Cx This function is applicable to either continuous- or discrete-time models.
initial initial(sys1,sys2,...,sysN,x0) initial(sys1,sys2,...,sysN,x0,t) (see impulse for details). When invoked with lefthand arguments, [y,t,x] = initial(sys,x0) [y,t,x] = initial(sys,x0,t) return the output response y, the time vector t used for simulation, and the state trajectories x. No plot is drawn on the screen. The array y has as many rows as time samples (length of t) and as many columns as outputs. Similarly, x has length(t) rows and as many columns as states.
initial initial(sys,x0) See Also impulse lsim ltiview step Impulse response Simulate response to arbitrary inputs LTI system viewer Step response 16-101
interp Purpose 16interp Syntax isys = interp(sys,freqs) interpolates the frequency response data contained in the FRD model sys at the frequencies freqs. interp, which is an overloaded version of the MATLAB function interp, uses linear interpolation and returns an FRD model isys containing the interpolated data at the new frequencies freqs. Interpolate an FRD model between frequency points You should express the frequency values freqs in the same units as sys.frequency.
inv Purpose 16inv Invert LTI systems Syntax isys = inv(sys) Description inv inverts the input/output relation y = G ( s )u –1 to produce the LTI system with the transfer matrix H ( s ) = G ( s ) . u = H ( s )y This operation is defined only for square systems (same number of inputs and outputs) with an invertible feedthrough matrix D . inv handles both continuous- and discrete-time systems.
inv H * Hi is the identity transfer function (static gain I). Limitations Do not use inv to model feedback connections such as + G - H While it seems reasonable to evaluate the corresponding closed-loop transfer –1 function ( I + GH ) G as inv(1+g*h) * g this typically leads to nonminimal closed-loop models. For example, g = zpk([],1,1) h = tf([2 1],[1 0]) cloop = inv(1+g*h) * g yields a third-order closed-loop model with an unstable pole-zero cancellation at s = 1.
isct, isdt Purpose 16isct, isdt Determine whether an LTI model is continuous or discrete Syntax boo = isct(sys) boo = isdt(sys) Description boo = isct(sys) returns 1 (true) if the LTI model sys is continuous and 0 (false) otherwise. sys is continuous if its sample time is zero, that is, sys.Ts=0. boo = isdt(sys) returns 1 (true) if sys is discrete and 0 (false) otherwise.
isempty Purpose 16isempty Test if an LTI model is empty Syntax boo = isempty(sys) Description isempty(sys) returns 1 (true) if the LTI model sys has no input or no output, and 0 (false) otherwise. Example Both commands isempty(tf) % tf by itself returns an empty transfer function isempty(ss(1,2,[],[])) return 1 (true) while isempty(ss(1,2,3,4)) returns 0 (false).
isproper Purpose Syntax Description 16isproper Test if an LTI model is proper boo = isproper(sys) isproper(sys) returns 1 (true) if the LTI model sys is proper and 0 (false) otherwise. State-space models are always proper. SISO transfer functions or zero-pole-gain models are proper if the degree of their numerator is less than or equal to the degree of their denominator. MIMO transfer functions are proper if all their SISO entries are proper.
issiso Purpose Syntax Description 16issiso Test if an LTI model is single-input/single-output (SISO) boo = issiso(sys) issiso(sys) returns 1 (true) if the LTI model sys is SISO and 0 (false) otherwise.
kalman Purpose 16kalman Design continuous- or discrete-time Kalman estimator Syntax [kest,L,P] = kalman(sys,Qn,Rn,Nn) [kest,L,P,M,Z] = kalman(sys,Qn,Rn,Nn) % discrete time only [kest,L,P] = kalman(sys,Qn,Rn,Nn,sensors,known) Description kalman designs a Kalman state estimator given a state-space model of the plant and the process and measurement noise covariance data. The Kalman estimator is the optimal solution to the following continuous or discrete estimation problems.
kalman the output and state estimates y and x .
kalman and generates optimal “current” output and state estimates y [ n n ] and x [ n n ] using all available measurements including y v [ n ] . The gain matrices L and M are derived by solving a discrete Riccati equation. The innovation gain M is used to update the prediction x̂ [ n n – 1 ] using the new measurement y v [ n ] .
kalman for more general plants sys where the known inputs u and stochastic inputs w are mixed together, and not all outputs are measured. The index vectors sensors and known then specify which outputs y of sys are measured and which inputs u are known. All other inputs are assumed stochastic. Example See LQG Design for the x-Axis and Kalman Filtering for examples that use the kalman function.
kalmd Purpose 16kalmd Design discrete Kalman estimator for continuous plant Syntax [kest,L,P,M,Z] = kalmd(sys,Qn,Rn,Ts) Description kalmd designs a discrete-time Kalman estimator that has response characteristics similar to a continuous-time estimator designed with kalman. This command is useful to derive a discrete estimator for digital implementation after a satisfactory continuous estimator has been designed.
kalmd lqgreg lqrd References Assemble LQG regulator Discrete LQ-optimal gain for continuous plant [1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of Dynamic Systems, Second Edition, Addison-Wesley, 1990. [2] Van Loan, C.F., “Computing Integrals Involving the Matrix Exponential,” IEEE Trans. Automatic Control, AC-15, October 1970.
lft Purpose 16lft Redheffer star product (linear fractional transformation) of two LTI models Syntax sys = lft(sys1,sys2) sys = lft(sys1,sys2,nu,ny) Description lft forms the star product or linear fractional transformation (LFT) of two LTI models or LTI arrays. Such interconnections are widely used in robust control techniques. sys = lft(sys1,sys2,nu,ny) forms the star product sys of the two LTI models (or LTI arrays) sys1 and sys2.
lft produces: • The lower LFT of sys1 and sys2 if sys2 has fewer inputs and outputs than sys1. This amounts to deleting w 2 and z 2 in the above diagram. • The upper LFT of sys1 and sys2 if sys1 has fewer inputs and outputs than sys2. This amounts to deleting w 1 and z 1 in the above diagram. z1 w1 sys1 sys1 u u y y sys2 sys2 z2 w2 Lower LFT connection Upper LFT connection Algorithm The closed-loop model is derived by elementary state-space manipulations.
lqgreg Purpose Syntax 16lqgreg Form LQG regulator given state-feedback gain and Kalman estimator rlqg = lqgreg(kest,k) rlqg = lqgreg(kest,k,'current') % discrete-time only rlqg = lqgreg(kest,k,controls) Description lqgreg forms the LQG regulator by connecting the Kalman estimator designed with kalman and the optimal state-feedback gain designed with lqr, dlqr, or lqry. The LQG regulator minimizes some quadratic cost function that trades off regulation performance and control effort.
lqgreg Process noise Plant y u u –K x̂ Kalman filter + yv + Measurement noise LQG regulator In discrete time, you can form the LQG regulator using either the prediction x̂ [ n n – 1 ] of x [ n ] based on measurements up to y v [ n – 1 ] , or the current state estimate x̂ [ n n ] based on all available measurements including y v [ n ] .
lqgreg • Discrete regulator for continuous plant: use lqrd and kalmd. In discrete time, lqgreg produces the regulator u [ n ] = – Kx̂ [ n n – 1 ] by default (see “Description”). To form the “current” LQG regulator instead, use u [ n ] = – Kx̂ [ n n ] the syntax rlqg = lqgreg(kest,k,'current') This syntax is meaningful only for discrete-time problems. rlqg = lqgreg(kest,k,controls) handles estimators that have access to additional known plant inputs u d .
lqgreg See Also 16-120 kalman kalmd lqr, dlqr lqrd lqry reg Kalman estimator design Discrete Kalman estimator for continuous plant State-feedback LQ regulator Discrete LQ regulator for continuous plant LQ regulator with output weighting Form regulator given state-feedback and estimator gains
lqr Purpose Syntax Description 16lqr Design linear-quadratic (LQ) state-feedback regulator for continuous plant [K,S,e] = lqr(A,B,Q,R) [K,S,e] = lqr(A,B,Q,R,N) [K,S,e] = lqr(A,B,Q,R,N) calculates the optimal gain matrix K such that the state-feedback law u = – Kx minimizes the quadratic cost function J(u) = ∞ ò0 ( x T T T Qx + u Ru + 2x Nu ) dt for the continuous-time state-space model x· = Ax + Bu The default value N=0 is assumed when N is omitted.
lqrd Purpose 16lqrd Design discrete LQ regulator for continuous plant Syntax [Kd,S,e] = lqrd(A,B,Q,R,Ts) [Kd,S,e] = lqrd(A,B,Q,R,N,Ts) Description lqrd designs a discrete full-state-feedback regulator that has response characteristics similar to a continuous state-feedback regulator designed using lqr. This command is useful to design a gain matrix for digital implementation after a satisfactory continuous state-feedback gain has been designed.
lqrd Φ( τ) = e Γ(τ) = Aτ τ ò0 e Ad = Φ ( Ts ) , Aη Bd = Γ( Ts ) B dη , the discretized plant has equations x [ n + 1 ] = Ad x [ n ] + Bd u [ n ] and the weighting matrices for the equivalent discrete cost function are Qd Nd T Nd Rd Ts = ò0 T Φ (τ) 0 Q N Φ( τ) Γ(τ ) dτ T T 0 I Γ (τ) I N R The integrals are computed using matrix exponential formulas due to Van Loan (see [2]). The plant is discretized using c2d and the gain matrix is computed from the discretized data using dlqr.
lqry Purpose 16lqry Linear-quadratic (LQ) state-feedback regulator with output weighting Syntax [K,S,e] = lqry(sys,Q,R) [K,S,e] = lqry(sys,Q,R,N) Description Given the plant x· = Ax + Bu y = Cx + Du or its discrete-time counterpart, lqry designs a state-feedback control u = – Kx that minimizes the quadratic cost function with output weighting J(u) = ∞ ò0 ( y T T T Qy + u Ru + 2y Nu ) dt (or its discrete-time counterpart).
lsim Purpose Syntax 16lsim Simulate LTI model response to arbitrary inputs lsim(sys,u,t) lsim(sys,u,t,x0) lsim(sys,u,t,x0,'zoh') lsim(sys,u,t,x0,'foh') lsim(sys1,sys2,...,sysN,u,t) lsim(sys1,sys2,...,sysN,u,t,x0) lsim(sys1,'PlotStyle1',...,sysN,'PlotStyleN',u,t) [y,t,x] = lsim(sys,u,t,x0) Description lsim simulates the (time) response of continuous or discrete linear systems to arbitrary inputs. When invoked without left-hand arguments, lsim plots the response on the screen.
lsim linear interpolation). By default, lsim selects the interpolation method automatically based on the smoothness of the signal U. Finally, lsim(sys1,sys2,...,sysN,u,t) simulates the responses of several LTI models to the same input history t,u and plots these responses on a single figure. As with bode or plot, you can specify a particular color, linestyle, and/or marker for each system, for example, lsim(sys1,'y:',sys2,'g--',u,t,x0) The multisystem behavior is similar to that of bode or step.
lsim H = [tf([2 5 1],[1 2 3]) ; tf([1 -1],[1 1 5])] lsim(H,u,t) Algorithm Discrete-time systems are simulated with ltitr (state space) or filter (transfer function and zero-pole-gain). Continuous-time systems are discretized with c2d using either the 'zoh' or 'foh' method ('foh' is used for smooth input signals and 'zoh' for discontinuous signals such as pulses or square waves). The sampling period is set to the spacing dt between the user-supplied time samples t.
lsim w2 = 62.83^2 h = tf(w2,[1 2 w2]) t = 0:0.1:5; u = (rem(t,1)>=0.5); lsim(h,u,t) % vector of time samples % square wave values lsim evaluates the specified sample time, gives this warning Warning: Input signal is undersampled. Sample every 0.016 sec or faster. and produces this plot. To improve on this response, discretize H ( s ) using the recommended sampling period: dt=0.016; ts=0:dt:5; us = (rem(ts,1)>=0.
lsim lsim(hd,us,ts) This response exhibits strong oscillatory behavior hidden from the undersampled version.
ltimodels Purpose Syntax 16ltimodels Help on LTI models ltimodels ltimodels(modeltype) Description ltimodels displays general information on the various types of LTI models supported in the Control System Toolbox. ltimodels(modeltype) gives additional details and examples for each type of LTI model.
ltiprops Purpose Syntax 16ltiprops Help on LTI model properties ltimodels ltimodels(modeltype) Description ltiprops displays details on the generic properties of LTI models. ltiprops(modeltype) gives details on the properties specific to the various types of LTI models. The string modeltype selects the model type among the following: • tf' — transfer functions (TF objects) • zpk — zero-pole-gain models (ZPK objects) • ss — state-space models (SS objects) • frd — frequency response data (FRD objects).
ltiview Purpose 16ltiview Initialize an LTI Viewer for LTI system response analysis Syntax ltiview ltiview(sys1,sys2,...,sysn) ltiview('plottype',sys1,sys2,...,sysn) ltiview('plottype',sys,extras) ltiview('clear',viewers) ltiview('current',sys1,sys2,...,sysn,viewers) Description ltiview when invoked without input arguments, initializes a new LTI Viewer for LTI system response analysis. ltiview(sys1,sys2,...,sysn) opens an LTI Viewer containing the step response of the LTI models sys1,sys2,...,sysn.
ltiview ltiview(plottype,sys,extras) allows the additional input arguments supported by the various LTI model response functions to be passed to the ltiview command. extras is one or more input arguments as specified by the function named in plottype. These arguments may be required or optional, depending on the type of LTI response. For example, if plottype is 'step' then extras may be the desired final time, Tfinal, as shown below.
ltiview nichols nyquist pzmap sigma step 16-134 Nichols response Nyquist response Pole/zero map Singular value response Step response
lyap Purpose 16lyap Solve continuous-time Lyapunov equations Syntax X = lyap(A,Q) X = lyap(A,B,C) Description lyap solves the special and general forms of the Lyapunov matrix equation. Lyapunov equations arise in several areas of control, including stability theory and the study of the RMS behavior of systems. X = lyap(A,Q) solves the Lyapunov equation T AX + XA + Q = 0 where A and Q are square matrices of identical sizes. The solution X is a symmetric matrix if Q is.
lyap References [1] Bartels, R.H. and G.W. Stewart, “Solution of the Matrix Equation AX + XB = C,” Comm. of the ACM, Vol. 15, No. 9, 1972. [2] Bryson, A.E. and Y.C. Ho, Applied Optimal Control, Hemisphere Publishing, 1975. pp. 328–338.
margin Purpose 16margin Compute gain and phase margins and associated crossover frequencies Syntax [Gm,Pm,Wcg,Wcp] = margin(sys) [Gm,Pm,Wcg,Wcp] = margin(mag,phase,w) margin(sys) Description margin calculates the minimum gain margin, phase margin, and associated crossover frequencies of SISO open-loop models. The gain and phase margins indicate the relative stability of the control system when the loop is closed.
margin Example You can compute the gain and phase margins of the open-loop discrete-time transfer function. Type hd = tf([0.04798 0.0464],[1 -1.81 0.9048],0.1) MATLAB responds with Transfer function: 0.04798 z + 0.0464 --------------------z^2 - 1.81 z + 0.9048 Sampling time: 0.1 Type [Gm,Pm,Wcg,Wcp] = margin(hd); [Gm,Pm,Wcg,Wcp] and MATLAB returns ans = 2.0517 13.5711 5.4374 4.3544 You can also display these margins graphically.
margin margin(hd) Algorithm The phase margin is computed using H ∞ theory, and the gain margin by solving H ( jω ) = H ( jω ) for the frequency ω .
minreal Purpose 16minreal Minimal realization or pole-zero cancellation Syntax sysr = minreal(sys) sysr = minreal(sys,tol) [sysr,u] = minreal(sys,tol) Description sysr = minreal(sys) eliminates uncontrollable or unobservable state in state-space models, or cancels pole-zero pairs in transfer functions or zero-pole-gain models. The output sysr has minimal order and the same response characteristics as the original model sys.
minreal Algorithm Pole-zero cancellation is a straightforward search through the poles and zeros looking for matches that are within tolerance. Transfer functions are first converted to zero-pole-gain form.
modred Purpose 16modred Model order reduction Syntax rsys = modred(sys,elim) rsys = modred(sys,elim,'mdc') rsys = modred(sys,elim,'del') Description modred reduces the order of a continuous or discrete state-space model sys. This function is usually used in conjunction with balreal.
modred The last three diagonal entries of the balanced grammians are small, so eliminate the last three states with modred using both matched DC gain and direct deletion methods. hmdc = modred(hb,2:4,'mdc') hdel = modred(hb,2:4,'del') Both hmdc and hdel are first-order models. Compare their Bode responses against that of the original model h ( s ) . bode(h,'-',hmdc,'x',hdel,'*') The reduced-order model hdel is clearly a better frequency-domain approximation of h ( s ) . Now compare the step responses.
modred step(h,'-',hmdc,'-.',hdel,'--') While hdel accurately reflects the transient behavior, only hmdc gives the true steady-state response. Algorithm The algorithm for the matched DC gain method is as follows. For continuous-time models x· = Ax + Bu y = Cx + Du the state vector is partitioned into x1 , to be kept, and x 2 , to be eliminated.
modred Next, the derivative of x 2 is set to zero and the resulting equation is solved for x 1 . The reduced-order model is given by –1 –1 x· 1 = [ A 11 – A 12 A 22 A 21 ]x 1 + [ B 1 – A 12 A 22 B 2 ]u –1 –1 y = [ C 1 – C 2 A 22 A 21 ]x + [ D – C 2 A 22 B 2 ]u The discrete-time case is treated similarly by setting x2 [ n + 1 ] = x2 [ n ] Limitations With the matched DC gain method, A 22 must be invertible in continuous time, and I – A 22 must be invertible in discrete time.
ndims Purpose 16ndims Provide the number of the dimensions of an LTI model or LTI array Syntax n = ndims(sys) Description n = ndims(sys) is the number of dimensions of an LTI model or an array of LTI models sys. A single LTI model has two dimensions (one for outputs, and one for inputs). An LTI array has 2+p dimensions, where p ≥ 2 is the number of array dimensions. For example, a 2-by-3-by-4 array of models has 2+3=5 dimensions.
ngrid Purpose 16ngrid Superimpose a Nichols chart on a Nichols plot Syntax ngrid Description ngrid superimposes Nichols chart grid lines over the Nichols frequency response of a SISO LTI system. The range of the Nichols grid lines is set to encompass the entire Nichols frequency response. The chart relates the complex number H ⁄ ( 1 + H ) to H , where H is any complex number.
ngrid ngrid See Also 16-148 nichols Nichols plots
nichols Purpose Syntax 16nichols Compute Nichols frequency response of LTI models nichols(sys) nichols(sys,w) nichols(sys1,sys2,...,sysN) nichols(sys1,sys2,...,sysN,w) nichols(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [mag,phase,w] = nichols(sys) [mag,phase] = nichols(sys,w) Description nichols computes the frequency response of an LTI model and plots it in the Nichols coordinates.
nichols [mag,phase,w] = nichols(sys) [mag,phase] = nichols(sys,w) return the magnitude and phase (in degrees) of the frequency response at the frequencies w (in rad/sec). The outputs mag and phase are 3-D arrays similar to those produced by bode (see the bode reference page).
nichols The right-click menu for Nichols plots includes the Tight option under Zoom. You can use this to clip unbounded branches of the Nichols plot. Algorithm See bode.
norm Purpose Syntax 16norm Compute LTI model norms norm(sys) norm(sys,2) norm(sys,inf) norm(sys,inf,tol) [ninf,fpeak] = norm(sys) Description norm computes the H 2 or L ∞ norm of a continuous- or discrete-time LTI model.
norm H(z) Usage ∞ = jθ max σ max ( H ( e ) ) θ ∈ [ 0, π ] norm(sys) or norm(sys,2) both return the H 2 norm of the TF, SS, or ZPK model sys. This norm is infinite in the following cases: • sys is unstable. • sys is continuous and has a nonzero feedthrough (that is, nonzero gain at the frequency ω = ∞ ). Note that norm(sys) produces the same result as sqrt(trace(covar(sys,1))) norm(sys,inf) computes the infinity norm of any type of LTI model sys.
norm ninf = 2.5488 fpeak = 3.0844 These values are confirmed by the Bode plot of H ( z ) .
norm 8.1268 Algorithm norm uses the same algorithm as covar for the H 2 norm, and the algorithm of [1] for the infinity norm. sys is first converted to state space. See Also bode freqresp sigma References Bode plot Frequency response computation Singular value plot [1] Bruisma, N.A. and M. Steinbuch, “A Fast Algorithm to Compute the H ∞ -Norm of a Transfer Function Matrix,” System Control Letters, 14 (1990), pp. 287–293.
nyquist Purpose Syntax 16nyquist Compute Nyquist frequency response of LTI models nyquist(sys) nyquist(sys,w) nyquist(sys1,sys2,...,sysN) nyquist(sys1,sys2,...,sysN,w) nyquist(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [re,im,w] = nyquist(sys) [re,im] = nyquist(sys,w) Description nyquist calculates the Nyquist frequency response of LTI models. When invoked without left-hand arguments, nyquist produces a Nyquist plot on the screen.
nyquist [re,im,w] = nyquist(sys) [re,im] = nyquist(sys,w) return the real and imaginary parts of the frequency response at the frequencies w (in rad/sec). re and im are 3-D arrays with the frequency as last dimension (see “Arguments” below for details).
nyquist nyquist(H) You have two zoom options available from the right-click menu that apply specifically to Nyquist plots: • Tight —Clips unbounded branches of the Nyquist plot, but still includes the critical point (-1, 0) • On (-1,0) — Zooms around the critical point (-1,0) 16-158
nyquist Also, click anywhere on the curve to activate data markers that display the real and imaginary values at a given frequency. This figure shows the nyquist plot with a data marker.
obsv Purpose 16obsv Form the observability matrix Syntax Ob = obsv(A,B) Ob = obsv(sys) Description obsv computes the observability matrix for state-space systems. For an n-by-n matrix A and a p-by-n matrix C, obsv(A,C) returns the observability matrix C CA Ob = CA : CA 2 n–1 with n columns and np rows. Ob = obsv(sys) calculates the observability matrix of the state-space model sys. This syntax is equivalent to executing Ob = obsv(sys.A,sys.C) The model is observable if Ob has full rank n.
obsv MATLAB responds with unob = 0 See Also obsvf Compute the observability staircase form 16-161
obsvf Purpose 16obsvf Compute the observability staircase form Syntax [Abar,Bbar,Cbar,T,k] = obsvf(A,B,C) [Abar,Bbar,Cbar,T,k] = obsvf(A,B,C,tol) Description If the observability matrix of (A,C) has rank r ≤ n , where n is the size of A, then there exists a similarity transformation such that T A = TAT , B = TB, C = CT T where T is unitary and the transformed system has a staircase form with the unobservable modes, if any, in the upper left corner.
obsvf 1 1 -1 -1 1 0 0 1 C = by typing [Abar,Bbar,Cbar,T,k] = obsvf(A,B,C) Abar = 1 4 Bbar = 1 1 Cbar = 1 0 T = 1 0 k = 2 1 -2 1 -1 0 1 0 1 0 Algorithm obsvf is an M-file that implements the Staircase Algorithm of [1] by calling ctrbf and using duality. See Also ctrbf obsv References Compute the controllability staircase form Calculate the observability matrix [1] Rosenbrock, M.M., State-Space and Multivariable Theory, John Wiley, 1970.
ord2 Purpose Syntax Description 16ord2 Generate continuous second-order systems [A,B,C,D] = ord2(wn,z) [num,den] = ord2(wn,z) [A,B,C,D] = ord2(wn,z) generates the state-space description (A,B,C,D) of the second-order system 1 h ( s ) = --------------------------------------------2 2 s + 2ζω n s + ω n given the natural frequency wn ( ω n ) and damping factor z ( ζ ). Use ss to turn this description into a state-space object.
pade Purpose Syntax 16pade Compute the Padé approximation of models with time delays [num,den] = pade(T,N) pade(T,N) sysx = pade(sys,N) sysx = pade(sys,NI,NO,Nio) Description pade approximates time delays by rational LTI models. Such approximations are useful to model time delay effects such as transport and computation delays within the context of continuous-time systems. The Laplace transform of an time delay of T seconds is exp ( – sT ) .
pade You can use scalar values to specify uniform approximation orders, and [] if there are no input, output, or I/O delays. Example Compute a third-order Padé approximation of a 0.1 second I/O delay and compare the time and frequency responses of the true delay and its approximation. To do this, type pade(0.1,3) Step response of 3rd−order Pade approximation 1.5 Amplitude 1 0.5 0 −0.5 −1 0 0.02 0.04 0.06 0.08 0.1 0.12 Time (secs) 0.14 0.16 0.18 0.2 Phase response 0 Phase (deg.
pade delay2z References Changes transfer functions of discrete-time LTI models with delays to rational functions or absorbs FRD delays into the frequency response phase information [1] Golub, G. H. and C. F. Van Loan, Matrix Computations, Johns Hopkins University Press, Baltimore, 1989, pp. 557–558.
parallel Purpose 16parallel Parallel connection of two LTI models Syntax sys = parallel(sys1,sys2) sys = parallel(sys1,sys2,inp1,inp2,out1,out2) Description parallel connects two LTI models in parallel. This function accepts any type of LTI model. The two systems must be either both continuous or both discrete with identical sample time. Static gains are neutral and can be specified as regular matrices. sys = parallel(sys1,sys2) forms the basic parallel connection shown below.
parallel sys = parallel(sys1,sys2,inp1,inp2,out1,out2) forms the more general parallel connection. sys v1 y1 u1 + + u u2 v2 z1 sys1 sys2 y y2 z2 The index vectors inp1 and inp2 specify which inputs u 1 of sys1 and which inputs u 2 of sys2 are connected. Similarly, the index vectors out1 and out2 specify which outputs y 1 of sys1 and which outputs y 2 of sys2 are summed. The resulting model sys has [ v 1 ; u ; v 2 ] as inputs and [ z 1 ; y ; z 2 ] as outputs.
place Purpose 16place Pole placement design Syntax K = place(A,B,p) [K,prec,message] = place(A,B,p) Description Given the single- or multi-input system x· = Ax + Bu and a vector p of desired self-conjugate closed-loop pole locations, place computes a gain matrix K such that the state feedback u = – Kx places the closed-loop poles at the locations p. In other words, the eigenvalues of A – BK match the entries of p (up to the ordering).
place Algorithm place uses the algorithm of [1] which, for multi-input systems, optimizes the choice of eigenvectors for a robust solution. We recommend place rather than acker even for single-input systems. In high-order problems, some choices of pole locations result in very large gains. The sensitivity problems attached with large gains suggest caution in the use of pole placement techniques. See [2] for results from numerical testing.
pole Purpose 16pole Compute the poles of an LTI system Syntax p = pole(sys) Description pole computes the poles p of the SISO or MIMO LTI model sys. Algorithm For state-space models, the poles are the eigenvalues of the A matrix, or the generalized eigenvalues of A – λE in the descriptor case. For SISO transfer functions or zero-pole-gain models, the poles are simply the denominator roots (see roots).
pzmap Purpose 16pzmap Compute the pole-zero map of an LTI model Syntax pzmap(sys) pzmap(sys1,sys2,...,sysN) [p,z] = pzmap(sys) Description pzmap(sys) plots the pole-zero map of the continuous- or discrete-time LTI model sys. For SISO systems, pzmap plots the transfer function poles and zeros. For MIMO systems, it plots the system poles and transmission zeros. The poles are plotted as x’s and the zeros are plotted as o’s. pzmap(sys1,sys2,...
pzmap pzmap(H) Algorithm pzmap uses a combination of pole and zero.
reg Purpose 16reg Form regulator given state-feedback and estimator gains Syntax rsys = reg(sys,K,L) rsys = reg(sys,K,L,sensors,known,controls) Description rsys = reg(sys,K,L) forms a dynamic regulator or compensator rsys given a state-space model sys of the plant, a state-feedback gain matrix K, and an estimator gain matrix L. The gains K and L are typically designed using pole placement or LQG techniques. The function reg handles both continuous- and discrete-time cases.
reg This regulator should be connected to the plant using positive feedback. Plant y u u State Estimator –K x̂ y Regulator rsys = reg(sys,K,L,sensors,known,controls) handles more general regulation problems where: • The plant inputs consist of controls u , known inputs u d , and stochastic inputs w . • Only a subset y of the plant outputs is measured. The index vectors sensors, known, and controls specify y , u d , and u as subsets of the outputs and inputs of sys.
reg Example Given a continuous-time state-space model sys = ss(A,B,C,D) with seven outputs and four inputs, suppose you have designed: • A state-feedback controller gain K using inputs 1, 2, and 4 of the plant as control inputs • A state estimator with gain L using outputs 4, 7, and 1 of the plant as sensors, and input 3 of the plant as an additional known input You can then connect the controller and estimator and form the complete regulation system by controls = [1,2,4]; sensors = [4,7,1]; known = [3];
reshape Purpose 16reshape Change the shape of an LTI array Syntax sys = reshape(sys,s1,s2,...,sk) sys = reshape(sys,[s1 s2 ... sk]) Description sys = reshape(sys,s1,s2,...,sk) (or, equivalently, sys = reshape(sys,[s1 s2 ... sk])) reshapes the LTI array sys into an s1-by-s2-by...-sk array of LTI models. Equivalently, sys = reshape(sys,[s1 s2 ... sk]) reshapes the LTI array sys into an s1-by-s2-by...-sk array of LTI models. With either syntax, there must be s1*s2*...*sk models in sys to begin with.
rlocus Purpose Syntax 16rlocus Evans root locus rlocus(sys) rlocus(sys,k) rlocus(sys1,sys2,...) [r,k] = rlocus(sys) r = rlocus(sys,k) Description rlocus computes the Evans root locus of a SISO open-loop model. The root locus gives the closed-loop pole trajectories as a function of the feedback gain k (assuming negative feedback). Root loci are used to study the effects of varying feedback gains on closed-loop pole locations.
rlocus n(s) h ( s ) = ----------d(s) the closed-loop poles are the roots of d(s) + k n(s) = 0 rlocus adaptively selects a set of positive gains k to produce a smooth plot. Alternatively, rlocus(sys,k) uses the user-specified vector k of gains to plot the root locus. rlocus(sys1,sys2,...) draws the root loci of multiple LTI models sys1, sys2,... on a single plot. You can specify a color, line style, and marker for each model, as in rlocus(sys1,'r',sys2,'y:',sys3,'gx').
rlocus rlocus(h) You can use the right-click menu for rlocus to add grid lines, zoom in or out, and invoke the Property Editor to customize the plot. Also, click anywhere on the curve to activate a data marker that displays the gain value, pole, damping, overshoot, and frequency at the selected point.
rss Purpose 16rss Generate stable random continuous test models Syntax sys sys sys sys Description rss(n) produces a stable random n-th order model with one input and one output and returns the model in the state-space object sys. = = = = rss(n) rss(n,p) rss(n,p,m) rss(n,p,m,s1,...,sn) rss(n,p) produces a random nth order stable model with one input and p outputs, and rss(n,m,p) produces a random n-th order stable model with m inputs and p outputs. The output sys is always a state-space model.
rss d = y1 y2 u1 -0.87631 0 u2 -0.32758 0 Continuous-time system.
series Purpose 16series Series connection of two LTI models Syntax sys = series(sys1,sys2) sys = series(sys1,sys2,outputs1,inputs2) Description series connects two LTI models in series. This function accepts any type of LTI model. The two systems must be either both continuous or both discrete with identical sample time. Static gains are neutral and can be specified as regular matrices. sys = series(sys1,sys2) forms the basic series connection shown below.
series The index vectors outputs1 and inputs2 indicate which outputs y 1 of sys1 and which inputs u 2 of sys2 should be connected. The resulting model sys has u as input and y as output. Example Consider a state-space system sys1 with five inputs and four outputs and another system sys2 with two inputs and three outputs. Connect the two systems in series by connecting outputs 2 and 4 of sys1 with inputs 1 and 2 of sys2.
set Purpose Syntax 16set Set or modify LTI model properties set(sys,'Property',Value) set(sys,'Property1',Value1,'Property2',Value2,...) set(sys,'Property') set(sys) Description set is used to set or modify the properties of an LTI model (see LTI Properties for background on LTI properties). Like its Handle Graphics counterpart, set uses property name/property value pairs to update property values.
set get(sys) a = 1 b = 2 c = 3 d = 0 e = [] Nx = 1 StateName = {''} Ts = 0 InputDelay = 0.1 OutputDelay = 0 ioDelay = 0 InputName = {'torque'} OutputName = {''} InputGroup = {0x2 cell} OutputGroup = {0x2 cell} Notes = {} UserData = -6 Property Values The following table lists the admissible values for each LTI property. N u and N y denotes the number of inputs and outputs of the underlying LTI model. For K-dimensional LTI arrays, let S 1, S 2, …, S K denote the array dimensions.
set Table 16-17: LTI Properties Property Name Ts Admissible Property Values • 0 (zero) for continuous-time systems • Sample time in seconds for discrete-time systems • -1 or [] for discrete systems with unspecified sample time Note: Resetting the sample time property does not alter the model data. Use c2d, d2c, or d2d for discrete/continuous and discrete/discrete conversions.
set Table 16-17: LTI Properties (Continued) Property Name Admissible Property Values OutputDelay Output delays specified with • Nonnegative real numbers for continuous-time models (seconds) • Integers for discrete-time models (number of sample periods) • Scalar when N y = 1 or system has uniform output delay • Vector of length N y to specify independent delay times for each output channel • Array of size N y -by- N u -by- S 1 -by-. . .
set Table 16-18: State-Space Model Properties (Continued) Property Name Admissible Property Values a, b, c, d, e Real-valued state-space matrices (multidimensional arrays, in the case of LTI arrays) with compatible dimensions for the number of states, inputs, and outputs. See The Size of LTI Array Data for SS Models.
set Table 16-20: ZPK Model Properties Property Name Admissible Property Values z, p • Vectors of zeros and poles (either real-valued or complex conjugate pairs of them) in SISO case • N y -by- N u cell arrays of vectors (entries are real-valued or in complex conjugate pairs) in MIMO case, for example, z = {[],[-1 0]} for a model with two inputs and one output • N y -by- N u -by- S 1 -by- …-by- S K -dimensional cell arrays for MIMO LTI arrays Variable • String 's' (default) or 'p' for continuous-time s
set z+2 h ( z ) = ---------------------------z 2 + 3z + 4 However, if you change the Variable to 'z^-1' (or 'q') by set(h,'Variable','z^-1'), the same command set(h,'num',[1 2],'den',[1 3 4]) now interprets the row vectors [1 2] and [1 3 4] as the polynomials 1 + 2z –1 –2 and 1 + 3z + 4z and produces: –1 –1 –1 1 + 2z h ( z ) = ---------------------------------------- = zh ( z ) –1 –2 1 + 3z + 4z Note Because the resulting transfer functions are different, make sure to use the convention consistent wi
sgrid Purpose 16sgrid Generate an s-plane grid of constant damping factors and natural frequencies Syntax sgrid sgrid(z,wn) Description sgrid generates, for pole-zero and root locus plots, a grid of constant damping factors from zero to one in steps of 0.1 and natural frequencies from zero to 10 rad/sec in steps of one rad/sec, and plots the grid over the current axis. If the current axis contains a continuous s-plane root locus diagram or pole-zero map, sgrid draws the grid over the plot.
sgrid See Also 16-194 pzmap rlocus zgrid Plot pole-zero map Plot root locus Generate z-plane grid lines
sigma Purpose Syntax 16sigma Singular values of the frequency response of LTI models sigma(sys) sigma(sys,w) sigma(sys,w,type) sigma(sys1,sys2,...,sysN) sigma(sys1,sys2,...,sysN,w) sigma(sys1,sys2,...,sysN,w,type) sigma(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [sv,w] = sigma(sys) sv = sigma(sys,w) Description sigma calculates the singular values of the frequency response of an LTI model. For an FRD model, sys, sigma computes the singular values of sys.Response at the frequencies, sys.frequency.
sigma w = {wmin,wmax}. To use particular frequency points, set w to the corresponding vector of frequencies. Use logspace to generate logarithmically spaced frequency vectors. The frequencies must be specified in rad/sec. sigma(sys,[],type) or sigma(sys,w,type) plots the following modified singular value responses: –1 type = 1 Singular values of the frequency response H the frequency response of sys. type = 2 Singular values of the frequency response I + H .
sigma Example Plot the singular value responses of 0 H( s) = s+1 -----------s+5 3s --------------------------2 s + s + 10 2 -----------s+6 and I + H ( s ) .
sigma sigma(H,[],2) Singular Values Singular Values (dB) 20 0 −20 −40 −60 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 Singular Values Singular Values (dB) 20 10 0 −10 −20 −30 −40 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 Algorithm sigma uses the svd function in MATLAB to compute the singular values of a complex matrix.
sisotool Purpose 16sisotool Initialize the SISO Design Tool Syntax sisotool sisotool(plant) sisotool(plant,comp) sisotool(views) sisotool(views,plant,comp) sisotool(views,plant,comp,options) Description When invoked without input arguments, sisotool opens a SISO Design GUI for interactive compensator design. This GUI allows you to design a single-input/single-output (SISO) compensator using root locus and Bode diagram techniques. By default, the SISO Design Tool: • Opens root locus and Bode diagrams.
sisotool This picture shows the SISO Design Tool. Use the menu bar to import/export models, and to edit them. Right-click menu functionality is available under the Edit menu. The feedback structure: Click on FS to change the feedback structure. Click on +/- to change the feedback sign. Compensator description: The default compensator is K=1. Use the right-click menu s to maipulate the compensator design and the plots’ appearances. Right-click in any plot region to open the menu.
sisotool For example sisotool('bode') opens a SISO Design Tool with only the Bode Diagrams on. sisotool(plant,comp,options) allows you to override the default compensator location and feedback sign by using an extra input argument options with the following fields: • options.Location = 'forward' — Compensator in the forward loop • options.Location = 'feedback' — Compensator in the feedback loop • options.Sign = −1 — Negative feedback • options.
size Purpose 16size Provide the output/input/array dimensions of LTI models, the model order of TF, SS, and ZPK models, and the number of frequencies of FRD models Syntax size(sys) d = size(sys) Ny = size(sys,1) Nu = size(sys,2) Sk = size(sys,2+k) Ns = size(sys,'order') Nf = size(sys,'frequency') Description When invoked without output arguments, size(sys) returns a vector of the number of outputs and inputs for a single LTI model.
size size(sys) 3x1 array of state-space models Each model has 3 outputs, 2 inputs, and 5 states.
sminreal Purpose 16sminreal Perform model reduction based on structure Syntax msys = sminreal(sys) Description msys = sminreal(sys) eliminates the states of the state-space model sys that don’t affect the input/output response. All of the states of the resulting state-space model msys are also states of sys and the input/output response of msys is equivalent to that of sys. sminreal eliminates only structurally non minimal states, i.e.
sminreal all of the states of sys, including those of sys2 are retained.
ss Purpose Syntax 16ss Specify state-space models or convert an LTI model to state space sys sys sys sys = = = = ss(a,b,c,d) ss(a,b,c,d,Ts) ss(d) ss(a,b,c,d,ltisys) sys = ss(a,b,c,d,'Property1',Value1,...,'PropertyN',ValueN) sys = ss(a,b,c,d,Ts,'Property1',Value1,...,'PropertyN',ValueN) sys_ss = ss(sys) sys_ss = ss(sys,'minimal') Description ss is used to create real-valued state-space models (SS objects) or to convert transfer function or zero-pole-gain models to state space.
ss with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the sample time unspecified. sys = ss(d) specifies a static gain matrix D and is equivalent to sys = ss([],[],[],d) sys = ss(a,b,c,d,ltisys) creates a state-space model with generic LTI properties inherited from the LTI model ltisys (including the sample time). See “Generic Properties” on page 2-26 for an overview of generic LTI properties.
ss sys = ss(A,B,C,D,0.05,'statename',{'position' 'velocity'},... 'inputname','force',... 'notes','Created 10/15/96') creates a discrete-time model with matrices A, B, C, D and sample time 0.05 second. This model has two states labeled position and velocity, and one input labeled force (the dimensions of A, B, C, D should be consistent with these numbers of states and inputs). Finally, a note is attached with the date of creation of the model.
ss 1 ------------ 0 H( s) = s + 2 0 1 See Also dss frd get set ssdata tf zpk s+1 -----------------------2 s +s+1 2 s +3 -----------------------2 s +s+1 Specify descriptor state-space models. Specify FRD models or convert to an FRD. Get properties of LTI models. Set properties of LTI models. Retrieve the A, B, C, D matrices of state-space model. Specify transfer functions or convert to TF. Specify zero-pole-gain models or convert to ZPK.
ss2ss Purpose 16ss2ss State coordinate transformation for state-space models Syntax sysT = ss2ss(sys,T) Description Given a state-space model sys with equations x· = Ax + Bu y = Cx + Du (or their discrete-time counterpart), ss2ss performs the similarity transformation x = Tx on the state vector x and produces the equivalent state-space model sysT with equations.
ssbal Purpose 16ssbal Balance state-space models using a diagonal similarity transformation Syntax [sysb,T] = ssbal(sys) [sysb,T] = ssbal(sys,condT) Description Given a state-space model sys with matrices ( A, B, C, D ) , [sysb,T] = ssbal(sys) computes a diagonal similarity transformation T and a scalar α such that TAT αCT –1 –1 TB ⁄ α 0 has approximately equal row and column norms.
ssbal Balance this model with ssbal by typing ssbal(sys) a = x1 x2 x3 x1 1 0 2560 x1 x2 x3 u1 0.125 0.5 32 y1 x1 0.8 y1 u1 0 x2 2500 100 64 x3 0.39063 1562.5 0 x2 20 x3 3.125 b = c = d = Continuous-time system. Direct inspection shows that the range of numerical values has been compressed by a factor 100 and that the B and C matrices now have nearly equal norms. Algorithm ssbal uses the MATLAB function balance to compute T and α .
ssdata Purpose 16ssdata Quick access to state-space model data Syntax [a,b,c,d] = ssdata(sys) [a,b,c,d,Ts] = ssdata(sys) Description [a,b,c,d] = ssdata(sys) extracts the matrix (or multidimensional array) data ( A, B, C, D ) from the state-space model (LTI array) sys. If sys is a transfer function or zero-pole-gain model (LTI array), it is first converted to state space. See Table 11-16, “State-Space Model Properties,” on page 11-195 for more information on the format of state-space model data.
stack Purpose 16stack Build an LTI array by stacking LTI models or LTI arrays along array dimensions of an LTI array Syntax sys = stack(arraydim,sys1,sys2,...) Description sys = stack(arraydim,sys1,sys2,...) produces an array of LTI models sys by stacking (concatenating) the LTI models (or LTI arrays) sys1,sys2,... along the array dimension arraydim. All models must have the same number of inputs and outputs (the same I/O dimensions). The I/O dimensions are not counted in the array dimensions.
step Purpose Syntax 16step Step response of LTI systems step(sys) step(sys,t) step(sys1,sys2,...,sysN) step(sys1,sys2,...,sysN,t) step(sys1,'PlotStyle1',...,sysN,'PlotStyleN') [y,t,x] = step(sys) Description step calculates the unit step response of a linear system. Zero initial state is assumed in the state-space case. When invoked with no output arguments, this function plots the step response on the screen. step(sys) plots the step response of an arbitrary LTI model sys.
step All systems must have the same number of inputs and outputs but may otherwise be a mix of continuous- and discrete-time systems. This syntax is useful to compare the step responses of multiple systems. You can also specify a distinctive color, linestyle, and/or marker for each system. For example, step(sys1,'y:',sys2,'g--') plots the step response of sys1 with a dotted yellow line and the step response of sys2 with a green dashed line.
step a = [-0.5572 -0.7814;0.7814 b = [1 -1;0 2]; c = [1.9691 6.4493]; sys = ss(a,b,c,0); step(sys) 0]; The left plot shows the step response of the first input channel, and the right plot shows the step response of the second input channel. Algorithm Continuous-time models are converted to state space and discretized using zero-order hold on the inputs.
tf Purpose Syntax 16tf Specify transfer functions or convert LTI model to transfer function form sys sys sys sys = = = = tf(num,den) tf(num,den,Ts) tf(M) tf(num,den,ltisys) sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN) sys = tf(num,den,Ts,'Property1',Value1,...
tf If all SISO entries of a MIMO transfer function have the same denominator, you can set den to the row vector representation of this common denominator. See “Examples” for more details. sys = tf(num,den,Ts) creates a discrete-time transfer function with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the sample time unspecified. The input arguments num and den are as in the continuous-time case and must list the numerator and denominator coefficients in descending powers of z .
tf • s = tf('s') to specify a TF model using a rational function in the Laplace variable, s. • z = tf('z',Ts) to specify a TF model with sample time Ts using a rational function in the discrete-time variable, z. Once you specify either of these variables, you can specify TF models directly as rational expressions in the variable s or z by entering your transfer function as a rational expression in either s or z.
tf Transfer function from input "current" to output... p + 1 torque: ------------p^2 + 2 p + 2 ang. velocity: 1 p Note how setting the 'variable' property to 'p' causes the result to be displayed as a transfer function of the variable p . Example 2 To use a rational expression to create a SISO TF model, type s = tf('s'); H = s/(s^2 + 2*s +10); This produces the same transfer function as h = tf([1 0],[1 2 10]); Example 3 Specify the discrete MIMO transfer function 1 ----------------z + 0.
tf A = –2 –1 , 1 –2 B = 1 1 , 2 –1 C = 1 0 , D = 0 1 To do this, type sys = ss([-2 -1;1 -2],[1 1;2 -1],[1 0],[0 1]) tf(sys) Transfer function from input 1 to output: s ------------s^2 + 4 s + 5 Transfer function from input 2 to output: s^2 + 5 s + 8 ------------s^2 + 4 s + 5 Example 5 You can use a for loop to specify a 10-by-1 array of SISO TF models.
tf 2 The polynomials z and z 2 + 2z + 3 are then specified by the row vectors [1 0 0] and [1 2 3], respectively. By contrast, DSP engineers prefer to write this transfer function as 1 –1 h ( z ) = ---------------------------------------–1 –2 1 + 2z + 3z and specify its numerator as 1 (instead of [1 0 0]) and its denominator as [1 2 3]. tf switches convention based on your choice of variable (value of the 'Variable' property). Variable Convention 'z' (default) Use the row vector [ak ...
tf See also filt for direct specification of discrete transfer functions using the DSP convention. Note that tf stores data so that the numerator and denominator lengths are made equal. Specifically, tf stores the values num = [0 1 1]; den = [1 2 3] for g (the numerator is padded with zeros on the left) and the values num = [1 1 0]; den = [1 2 3] for h (the numerator is padded with zeros on the right).
tfdata Purpose 16tfdata Quick access to transfer function data Syntax [num,den] = tfdata(sys) [num,den] = tfdata(sys,'v') [num,den,Ts] = tfdata(sys) Description [num,den] = tfdata(sys) returns the numerator(s) and denominator(s) of the transfer function for the TF, SS or ZPK model (or LTI array of TF, SS or ZPK models) sys.
tfdata you can extract the numerator and denominator coefficients by typing [num,den] = tfdata(h,'v') num = 0 1 1 den = 1 2 5 This syntax returns two row vectors. If you turn h into a MIMO transfer function by typing H = [h ; tf(1,[1 1])] the command [num,den] = tfdata(H) now returns two cell arrays with the numerator/denominator data for each SISO entry. Use celldisp to visualize this data. Type celldisp(num) and MATLAB returns the numerator vectors of the entries of H.
tfdata tf zpkdata Specify transfer functions Quick access to zero-pole-gain data 16-227
totaldelay Purpose 16totaldelay Return the total combined I/O delays for an LTI model Syntax td = totaldelay(sys) Description td = totaldelay(sys) returns the total combined I/O delays for an LTI model sys. The matrix td combines contributions from the InputDelay, OutputDelay, and ioDelay properties, (see set on page 11-192 or type ltiprops for details on these properties).
zero Purpose 16zero Transmission zeros of LTI models Syntax z = zero(sys) [z,gain] = zero(sys) Description zero computes the zeros of SISO systems and the transmission zeros of MIMO systems. For a MIMO system with matrices ( A, B, C, D ) , the transmission zeros are the complex values λ for which the normal rank of A – λI B C D drops. z = zero(sys) returns the (transmission) zeros of the LTI model sys as a column vector.
zgrid Purpose 16zgrid Generate a z-plane grid of constant damping factors and natural frequencies Syntax zgrid zgrid(z,wn) Description zgrid generates, for root locus and pole-zero maps, a grid of constant damping factors from zero to one in steps of 0.1 and natural frequencies from zero to π in steps of π ⁄ 10 , and plots the grid over the current axis.
zgrid To see the z-plane grid on the root locus plot, type rlocus(H) zgrid axis('square') See Also pzmap rlocus sgrid Plot pole-zero map of LTI systems Plot root locus Generate s-plane grid lines 16-231
zpk Purpose Syntax 16zpk Specify zero-pole-gain models or convert LTI model to zero-pole-gain form sys sys sys sys = = = = zpk(z,p,k) zpk(z,p,k,Ts) zpk(M) zpk(z,p,k,ltisys) sys = zpk(z,p,k,'Property1',Value1,...,'PropertyN',ValueN) sys = zpk(z,p,k,Ts,'Property1',Value1,...
zpk • z = zpk('z',Ts) to specify a ZPK model with sample time Ts from a rational transfer function of the discrete-time variable, z. Once you specify either of these variables, you can specify ZPK models directly as real-valued rational expressions in the variable s or z. To create a MIMO zero-pole-gain model, specify the zeros, poles, and gain of each SISO entry of this model.
zpk sys = zpk(z,p,k,'Property1',Value1,...,'PropertyN',ValueN) is a shortcut for the following sequence of commands. sys = zpk(z,p,k) set(sys,'Property1',Value1,...,'PropertyN',ValueN) Zero-Pole-Gain Models as Rational Expressions in s or z You can also use rational expressions to create a ZPK model. To do so, first type either: • s = zpk('s') to specify a ZPK model using a rational function in the Laplace variable, s.
zpk 1 ----------------z – 0.3 H( z ) = 2 ( z + 0.5 ) -----------------------------------------------------------( z – 0.1 + j ) ( z – 0.1 – j ) To do this, type z p k H = = = = {[] ; -0.5} {0.3 ; [0.1+i 0.
zpk (z+0.3)^2 Sampling time: 0.1 Algorithm zpk uses the MATLAB function roots to convert transfer functions and the functions zero and pole to convert state-space models.
zpkdata Purpose 16zpkdata Quick access to zero-pole-gain data Syntax [z,p,k] = zpkdata(sys) [z,p,k] = zpkdata(sys,'v') [z,p,k,Ts,Td] = zpkdata(sys) Description [z,p,k] = zpkdata(sys) returns the zeros z, poles p, and gain(s) k of the zeropole-gain model sys. The outputs z and p are cell arrays with the following characteristics: • z and p have as many rows as outputs and as many columns as inputs.
zpkdata Zero/pole/gain from input to output... 1 #1: ------(z-0.3) #2: 2 (z+0.5) ------------------(z^2 - 0.2z + 1.01) Sampling time: unspecified you can extract the zero/pole/gain data embedded in H with [z,p,k] = zpkdata(H) z = [ 0] [-0.5000] p = [ 0.3000] [2x1 double] k = 1 2 To access the zeros and poles of the second output channel of H, get the content of the second cell in z and p by typing z{2,1} ans = -0.5000 p{2,1} ans = 0.1000+ 1.0000i 0.1000- 1.
zpkdata zpk Specify zero-pole-gain models 16-239
zpkdata 16-240
Index Symbols 16-228 A acker 16-11 addition of LTI models 3-11 scalar 3-12 adjoint. See pertransposition algebraic loop 16-77 append 3-16, 5-28, 16-13 array dimensions 5-7 arrays. See LTI arrays augstate 16-16 B balancing realizations 4-7, 16-17 balreal 16-17 block diagram.
Index crossover frequencies allmargin 16-12 margin 16-137 ctrb 16-45 ctrbf 16-47 customizing plots 9-3 SISO Design Tool 9-11 D d2c 16-49 d2d 3-26, 16-52 damp 16-53 damping 16-53 dare 16-55 dcgain 16-58 delay2z 16-59 delays combining 2-52, 16-228 conversion 16-59 delay2z 16-59 discrete-time models 2-50 discretization 3-23 existence of, test for 16-94 hasdelay 16-94 I/O 2-25, 2-43, 2-44, 16-188 information, retrieving 2-52 input 2-25, 2-48, 16-188 output 2-25, 2-43, 2-48, 16-189 Padé approximation 2-52, 16-
Index Tustin method 3-22 zero-order hold 3-20 dlqr 16-60 dlyap 16-62 drmodel 16-63 drss 16-63 dsort 16-65 DSP convention 16-78 dss 16-66 dssdata 16-68 dual.
Index G gain 2-11 feedthrough 2-27 low frequency (DC) 16-58 property LTI properties gain 2-27 state-feedback gain 16-60 gain margins 10-28, 16-21 gensig 16-88 get 2-30, 16-90 gram 16-92 gramian (gram) 16-17 group.
Index Kalman estimator continuous 10-36 current 16-111 discrete 10-50, 16-109 innovation 16-111 steady-state 16-109 time-varying 10-57 kalmd 16-113 L LFT (linear-fractional transformation) 16-115 LQG (linear quadratic-gaussian) method continuous LQ regulator 10-36, 16-121 cost function 10-36, 16-60 current regulator 16-118 design 10-31, 10-46 discrete LQ regulator 16-60 Kalman state estimator 16-109 LQ-optimal gain 10-36, 16-121 optimal state-feedback gain 16-121 regulator 10-31, 16-117 lqr 16-121 lqrd 16
Index interconnection functions 3-16 inversion 3-13 model data, accessing 2-23 model order reduction 16-142 model order reduction (balanced realization) 16-17 modifying 3-5 multiplication 3-13 ndims 16-146 norms 16-152 operations 3-1 precedence rules 3-3 See also operations proper transfer function 4-2, 16-107 random 16-182 resizing 3-9 second-order 16-164 SISO 16-108 ss 16-206 subsystem, modifying 3-9 subtraction 3-12 type 4-2 zpk 16-232 LTI objects 2-25, 2-31 constructing 2-4 methods 2-4 properties.
Index multiplication 3-13 scalar 3-13 N natural frequency 16-53 ndims 16-146 ngrid 16-147 Nichols chart 16-147 plot (nichols) 16-149 nichols 16-149 noise measurement 16-71 process 16-71 white 16-42 norm 16-152 norms of LTI systems (norm) 16-152 Notes 2-26 numerator property 2-27, 16-190 specification 2-8, 2-10, 2-21, 16-78 value 2-23, 16-91 numerical stability 11-6 Nyquist frequency 16-25 plot (nyquist) 16-156 nyquist 16-156 O object-oriented programming 2-4 objects.
Index P pade 16-165 Padé approximation (pade) 2-52, 16-165 parallel 16-168 parallel connection 3-12, 10-54, 16-168 pertransposition 3-14 phase margins 10-28, 16-21 place 16-170 plot customization 9-3 plotting multiple systems 16-21 Nichols chart (ngrid) 16-147 s-plane grid (sgrid) 16-193 z-plane grid (zgrid) 16-230 pole 16-172 pole placement 16-170 poles 2-12 computing 16-172 damping 16-53 equivalent continuous poles 16-53 multiple 16-172 natural frequency 16-53 pole-zero map 16-173 property 2-27 sorting
Index root locus design 10-9, 10-24 plot (rlocus) 16-179 See also Root Locus Design GUI rss 16-182 building an LTI array with 5-12 S sample time 2-19, 2-25, 2-26, 2-33, 3-3 accessing 2-23 resampling 3-26, 16-52 setting 2-34, 16-188 unspecified 2-26, 16-25 scaling 11-15 second-order model 16-164 series 16-184 series connection 3-13, 10-15, 16-184 set 2-28, 16-186 simulation of linear systems.
Index specification 2-14, 16-206 ss 2-14, 16-206 transfer functions of 2-40 step response 16-215 subsystem 2-6, 3-5 subsystem operations on LTI models subsystem, modifying 3-9 subtraction 3-12 Sylvester equation 16-135 symplectic pencil 16-56 T Td. See delays tf 2-8, 16-218 TF objects. See transfer functions tfdata output, form of 2-23 time delays.
Index quick data retrieval (zpkdata) 16-237 specification 2-12, 16-232 static gain 16-233 zpk 2-12, 16-232 zeros 2-12 computing 16-229 pole-zero map 16-173 property 2-27 transmission 16-229 zpk 2-12, 16-232 ZPK objects.