2 Building Models Converting Between Model Representations Now that you have a state-space representation of the dC motor, you can convert to other model representations, including transfer function(TF) and zero/pole/gain(zPK) models Transfer Function Representation. You can use tf to convert from the state-space representation to the transfer function. For example, use this code to convert to the transfer function representation of the DC motor sys_tf tf(sys_dc) Transfer functi on 1.5 s^2+14s+40.02 Zero/ Pole/Gain Representation. Similarly, the zpk function converts from state-space or transfer function representations to the zero/pole/gain format. Use this code to convert from the state-space representation to the zero/p gain form for the DC motor sys_zpk zpk(sys_dc) Zero/pole/gain: 1.5 (s+4.004)(s+9.996) Note The state-space representation is best suited for numerical computations. For highest accuracy, convert to state space prior to combining models and avoid the transfer function and zero/pole/gain representations, except for model specification and inspection. See"Reliable Computations online for more information on numerical issues 2-8
2 Building Models 2-8 Converting Between Model Representations Now that you have a state-space representation of the DC motor, you can convert to other model representations, including transfer function (TF) and zero/pole/gain (ZPK) models. Transfer Function Representation. You can use tf to convert from the state-space representation to the transfer function. For example, use this code to convert to the transfer function representation of the DC motor. sys_tf = tf(sys_dc) Transfer function: 1.5 ------------------ s^2 + 14 s + 40.02 Zero/Pole/Gain Representation. Similarly, the zpk function converts from state-space or transfer function representations to the zero/pole/gain format. Use this code to convert from the state-space representation to the zero/pole/ gain form for the DC motor. sys_zpk = zpk(sys_dc) Zero/pole/gain: 1.5 ------------------- (s+4.004) (s+9.996) Note The state-space representation is best suited for numerical computations. For highest accuracy, convert to state space prior to combining models and avoid the transfer function and zero/pole/gain representations, except for model specification and inspection. See “Reliable Computations” online for more information on numerical issues
Constructing Transfer Function and Zero/Pole/Gain Models In the DC motor example, the state-space approach produced a set of matrices that represents the model. If you choose a different approach, you can construct the corresponding models using tf, zpk, ss, or frd. sys tf(num, den) % Transfer functi on sys zpk (z, p, k) Zero/pole/gain ys= ss(a, b, C, d) State-space sys frd(response, frequenci es)% Frequency response data For example, if you want to create the transfer function of the dC motor directly, use ese comma sys_tf=1.5/(s^2+14*s+40.02) The Control System Toolbox builds this transfer function Transfer functi on: 5 s^2+14s+40.02 Alternatively, you can create the transfer function by specifying the numerator nd denominator with this code sys_tf=tf(1.5,[11440.02]) Transfer functi on To build the zero/pole/ga an model use this comma sys_zpk=zpk(Il.[-9.996-4.004],1.5) This is the resulting zero/pole/gain representation. polegai n: 1.5 (s+9.996)(s+4.004) 2-9
Linear Models 2-9 Constructing Transfer Function and Zero/Pole/Gain Models In the DC motor example, the state-space approach produced a set of matrices that represents the model. If you choose a different approach, you can construct the corresponding models using tf, zpk, ss, or frd. sys = tf(num,den) % Transfer function sys = zpk(z,p,k) % Zero/pole/gain sys = ss(a,b,c,d) % State-space sys = frd(response,frequencies) % Frequency response data For example, if you want to create the transfer function of the DC motor directly, use these commands. s = tf('s'); sys_tf = 1.5/(s^2+14*s+40.02) The Control System Toolbox builds this transfer function. Transfer function: 1.5 -------------------- s^2 + 14 s + 40.02 Alternatively, you can create the transfer function by specifying the numerator and denominator with this code. sys_tf = tf(1.5,[1 14 40.02]) Transfer function: 1.5 ------------------ s^2 + 14 s + 40.02 To build the zero/pole/gain model, use this command. sys_zpk = zpk([],[-9.996 -4.004], 1.5) This is the resulting zero/pole/gain representation. Zero/pole/gain: 1.5 ------------------- (s+9.996) (s+4.004)
2 Building Models Discrete Time Systems The Control Systems Toolbox provides full support for discrete time systems. You can create discrete systems in the same way that you create analo the only difference is that you must specify a sample time period for any model you build. For example, creates a siso model in the transfer function format Transfer functi on: tl 0.01 Adding Time Delays to Discrete-Time Models You can add time delays to discrete-time models by specifying an input or output time delay when building the model. The time delay must be a nonnegative integer that represents a multiple of the sampling time. For example sys_del ay tf(l, [1 1,0.01, ' output del ay,5); produces a system with an output delay of 0.05 second For a complete description of time delays, see "Adding Time Delays to Models online under the Control System Toolbox 2-10
2 Building Models 2-10 Discrete Time Systems The Control Systems Toolbox provides full support for discrete time systems. You can create discrete systems in the same way that you create analog systems; the only difference is that you must specify a sample time period for any model you build. For example, sys_disc = tf(1, [1 1], .01); creates a SISO model in the transfer function format. Transfer function: 1 ----- z + 1 Sampling time: 0.01 Adding Time Delays to Discrete-Time Models You can add time delays to discrete-time models by specifying an input or output time delay when building the model. The time delay must be a nonnegative integer that represents a multiple of the sampling time. For example, sys_delay = tf(1, [1 1], 0.01,'outputdelay',5); produces a system with an output delay of 0.05 second. Transfer function: 1 z^(-5) * ----- z + 1 Sampling time: 0.01 For a complete description of time delays, see “Adding Time Delays to Models” online under the Control System Toolbox
Adding Delays to Linear Models You can add time delays to linear models by specifying an input or output delay when building a model. For example, to add an input delay to the dC motor use this code sys_tfdel tf(1.5,[11440.02]. i nput del ay',0.05) Control System Toolbox constructs the DC motor transfer function, but 0.05 nd del Transfer functi on s^2+14s+40.02 For a complete description of adding time delays to models, see"Time Delays online under "Creating and Manipulating Models LTI Objects For convenience, the Control System Toolbox uses custom data structures called LTI objects to store model-related data. For example, the variable sys_dc created for the DC motor example is called an SS object. There are also TF, ZPK, and FRD objects for transfer function, zero/pole/gain, and frequency data response models respectively. The four LTI objects encapsulate the model data and enable you to manipulate linear systems as single entities rather than To see what LTI objects contain, use the get command. This code describes the contents of sys_dc from the dC motor example a: 2x2 doublel b: [ 2xl doublel 01 StateName: i 2xl cell) i oDel 2-11
Linear Models 2-11 Adding Delays to Linear Models You can add time delays to linear models by specifying an input or output delay when building a model. For example, to add an input delay to the DC motor, use this code. sys_tfdelay = tf(1.5, [1 14 40.02],'inputdelay',0.05) The Control System Toolbox constructs the DC motor transfer function, but adds a 0.05 second delay. Transfer function: 1.5 exp(-0.05*s) * ------------------ s^2 + 14 s + 40.02 For a complete description of adding time delays to models, see “Time Delays” online under “Creating and Manipulating Models.” LTI Objects For convenience, the Control System Toolbox uses custom data structures called LTI objects to store model-related data. For example, the variable sys_dc created for the DC motor example is called an SS object. There are also TF, ZPK, and FRD objects for transfer function, zero/pole/gain, and frequency data response models respectively. The four LTI objects encapsulate the model data and enable you to manipulate linear systems as single entities rather than as collections of vectors or matrices. To see what LTI objects contain, use the get command. This code describes the contents of sys_dc from the DC motor example. get(sys_dc) a: [2x2 double] b: [2x1 double] c: [0 1] d: 0 e: [] StateName: {2x1 cell} Ts: 0 ioDelay: 0 InputDelay: 0 OutputDelay: 0
2 Building Models I nput Name:I') I nput Group: (0x2 cell) Out put Group: (Ox2 cell) You can manipulate the data contained in LTI objects using the set command; see the Control System Toolbox online reference pages for descriptions of set and get For more information on LTI properties, type lti props at the matlaB prompt For a complete description of LTI objects, see"Creating and Manipulating Models"online under the Control System Toolbox
2 Building Models 2-12 InputName: {''} OutputName: {''} InputGroup: {0x2 cell} OutputGroup: {0x2 cell} Notes: {} UserData: [] You can manipulate the data contained in LTI objects using the set command; see the Control System Toolbox online reference pages for descriptions of set and get. For more information on LTI properties, type ltiprops at the MATLAB prompt. For a complete description of LTI objects, see “Creating and Manipulating Models” online under the Control System Toolbox