Creating LTI Models D(s)= s2+4s+5 You can specify this MIMO transfer matrix H(s)by typing n=f[1-1:[1 211: cell array for N(s) D=f[1 1:[1 4513;% cell array for D(s) H= tf(N, D) MATLAB responds with Transfer functi on from input to out put s 2 ^2+4s+5 Notice that both N and d have the same dimensions as H For a general MIMO transfer matrix H(s), the cell array entries N(i, j and Di,j) should be row-vector representations of the numerator and denominator of Hi(s), the iith entry of the transfer matrix H(S) Pure gains You can use tf with only one argument to specify simple gains or gain matrices as TF objects. For example, G=tf(I10;21]) produces the gain matrix whil E= tf creates an empty transfer function 2-11
Creating LTI Models 2-11 You can specify this MIMO transfer matrix 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 s + 2 #2: ------------- s^2 + 4 s + 5 Notice that both N and D have the same dimensions as H. For a general MIMO transfer matrix , the cell array entries N{i,j} and D{i,j} should be row-vector representations of the numerator and denominator of , the entry of the transfer matrix . Pure Gains You can use tf with only one argument to specify simple gains or gain matrices as TF objects. For example, G = tf([1 0;2 1]) produces the gain matrix while E = tf creates an empty transfer function. N s( ) s – 1 s + 2 = D s( ) s + 1 s2 + + 4s 5 = H s( ) H s( ) Hij(s) ijth H s( ) G 1 0 2 1 =
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 h(s)=kS-21)…(s-zm) (S-P1)…(S-Pn) where k is a real-valued scalar(the gain), and z1,.,Zm and P1,.,Pn are the eal or complex conjugate pairs of zeros and poles of the transfer function h(s) This model is closely related to the transfer function representation: the zeros are simply the numerator roots, and the poles, the denominator roots There are two ways to specify siso zero-pole-gain models · Using the zpk command As rational expressions in the Laplace variable s The syntax to specify ZPK models directly using zpk is h= zpk(z, p, k) where z and p are the vectors of zeros and poles, and k is the gain. This produces a ZPK object h that encapsulates the z, p, and k data. For example, pk(0,.[1-i1+i2 ces Zero/pole/gain: You can also specify zero-pole-gain models as rational expressions in the Laplace variable s by
2 LTI Models 2-12 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 where is a real-valued scalar (the gain), and ,..., and ,..., are the real or complex conjugate pairs of zeros and poles of the transfer function . This model is closely related to the transfer function representation: the zeros are simply the numerator roots, and the poles, the denominator roots. There are two ways to specify SISO zero-pole-gain models: • Using the zpk command • As rational expressions in the Laplace variable s The syntax to specify ZPK models directly using zpk is h = zpk(z,p,k) where z and p are the vectors of zeros and poles, and k is the gain. This produces a ZPK object h that encapsulates the z, p, and k data. For example, typing h = zpk(0, [1–i 1+i 2], –2) produces Zero/pole/gain: –2 s -------------------- (s–2) (s^2 – 2s + 2) You can also specify zero-pole-gain models as rational expressions in the Laplace variable s by: h s( ) k s z1 ( ) – ... ( ) s z – m s p1 ( ) – ... s pn ( ) – = ------------------------------------------------ k z1 zm p1 pn h s( )
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 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. See"Model Conversion"on page 2-40 for more information on conversion te other model types. MIMO Zero-Pole- Gain models Just as with TF models, you can also specify a MIMo ZPK model by concatenation of its siso entries(see"Model Interconnection Functions"on You can also use the command zpk to specify MIMO ZPK models. The syntax to create a p-by-m MIMO zero-pole-gain model using zpk is Z is the p-by-m cell array of zeros(Z(i,j)=zeros of His) P is the p-by-m cell array of poles(P(i,j)=poles of Hi s) k is the p-by-m matrix of gains((i,j)=gain of His) Z={[],-5:[1-i1+il[} P={0,[-1-1l;[123,[} 2-13
Creating LTI Models 2-13 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. See “Model Conversion” on page 2-40 for more information on conversion to other model types. MIMO Zero-Pole-Gain Models Just as with TF models, you can also specify a MIMO ZPK model by concatenation of its SISO entries (see “Model Interconnection Functions” on page 3-16). You can also use the command zpk to specify MIMO ZPK models. The syntax to create a p-by-m MIMO zero-pole-gain model using zpk is H = zpk(Z,P,K) where • Z is the p-by-m cell array of zeros (Z{i,j} = zeros of ) • P is the p-by-m cell array of poles (P{i,j} = poles of ) • K is the p-by-m matrix of gains (K(i,j) = gain of ) For example, typing Z = {[],–5;[1–i 1+i] []}; P = {0,[–1 –1];[1 2 3],[]}; Hij( ) s Hij( ) s Hij( ) s
2 LTI Models -13:20 H= zpk(z, P, k) creates the two-input/two-output zero-pole-gain model 3(S+5) H(s)= s+1 2(S2 (s-1)(s-2)(s-3) Notice that you use I 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. Continuous-time models are of the form dx Cx+ u where x is the state vector and u and yare the input and output vectors Such models may arise from the equations of physics, from state-space identification, or by state-space realization of the system transfer function Use the command ss to create state-space models sys ss(A, B, C, D) For del with n A is an Nx-by-Nx real-valued matrix B is an Nx- Nu real- valued matrix. D is an Ny-by-Nu real-valued matrix. This produces an SS object sys that stores the state-space matrices A, B, C, and D For models with a zero D matrix, you can useD =0(zero)as a shorthand for a zero matrix of the appropriate dimensions
2 LTI Models 2-14 K = [–1 3;2 0]; H = zpk(Z,P,K) creates the two-input/two-output zero-pole-gain model Notice that you use [] as a place-holder in Z (or P) when the corresponding entry of has no zeros (or poles). State-Space Models State-space models rely on linear differential or difference equations to describe the system dynamics. Continuous-time models are of the form where x is the state vector and u and y are the input and output vectors. Such models may arise from the equations of physics, from state-space identification, or by state-space realization of the system transfer function. Use the command ss to create state-space models sys = ss(A,B,C,D) For a model with Nx states, Ny outputs, and Nu inputs • A is an Nx-by-Nx real-valued matrix. • B is an Nx-by-Nu real-valued matrix. • C is an Ny-by-Nx real-valued matrix. • D is an Ny-by-Nu real-valued matrix. This produces an SS object sys that stores the state-space matrices . For models with a zero D matrix, you can use D = 0 (zero) as a shorthand for a zero matrix of the appropriate dimensions. H s( ) –1 s ------ 3( ) s + 5 ( ) s + 1 2 -------------------- 2 s2 ( ) – 2s + 2 ( ) s – 1 ( ) s – 2 ( ) s – 3 -------------------------------------------------- 0 = H s( ) dx dt ------ = Ax Bu + y Cx Du = + ABC ,,, and D
Creating LTI Models As an illustration, consider the following simple model of an electric motor d2e+2+56=3r where 0 is the angular displacement of the rotor and I the driving current. The elation between the input current u= I and the angular velocity y da/di is described by the state-space equations dx dt where B C This model is specified by typing sys=ss(01;-5-21.[0:3l,[011.0) to which MATLAB respond 1.00000 5.00000 -2.00000 3.00000 1.00000 2-15
Creating LTI Models 2-15 As an illustration, consider the following simple model of an electric motor. where is the angular displacement of the rotor and the driving current. The relation between the input current and the angular velocity is described by the state-space equations where This model is specified by typing sys = ss([0 1;–5 –2],[0;3],[0 1],0) to which MATLAB responds a = x1 x2 x1 0 1.00000 x2 –5.00000 –2.00000 b = u1 x1 0 x2 3.00000 c = x1 x2 y1 0 1.00000 d = u1 y1 0 d2θ t2 d --------- 2dθ dt + + ------ 5θ = 3I θ I u I = y d = θ ⁄ dt dx dt ------ = Ax Bu + y Cx = x θ dθ dt ------ = A 0 1 –5 –2 = B 0 3 = C = 0 1