Creating LTI Models

Transfer Function Models

This section explains how to specify continuous-time SISO and MIMO transfer function models. The specification of discrete-time transfer function models is a simple extension of the continuous-time case (see Creating Discrete-Time Models). In this section you can also read about how to specify transfer functions consisting of pure gains.

SISO Transfer Function Models

A continuous-time SISO transfer function

is characterized by its numerator and denominator , both polynomials of the Laplace variable s.

There are two ways to specify SISO transfer functions:

To specify a SISO transfer function model using the tf command, type

h = tf(num,den)

where num and den are row vectors listing the coefficients of the polynomials and , 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.

For example, you can create the transfer function by typing

h = tf([1 0],[1 2 10])

This command results in

Transfer function:
       s
--------------
s^2 + 2 s + 10

Note the customized display used for TF objects.

You can also specify transfer functions as rational expressions in the Laplace variable s by:

  1. Defining the variable s as a special TF model

    s = tf('s');
    
  2. Entering your transfer function as a rational expression in s

For example, once s is defined with tf as in 1,

H = s/(s^2 + 2*s +10);

produces the same transfer function as

h = tf([1 0],[1 2 10]);

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:

Consider the rational transfer matrix

.

You can specify by concatenation of its SISO entries. For instance,

h11 = tf([1 -1],[1 1]);		
h21 = tf([1 2],[1 4 5]);		

or, equivalently,

s = tf('s')
h11 = (s-1)/(s+1);
h21 = (s+2)/(s^2+4*s+5); 

can be concatenated to form .

H = [h11; h21]

This syntax mimics standard matrix concatenation and tends to be easier and more readable for MIMO systems with many inputs and/or outputs. See Model Interconnection Functions for more details on concatenation operations for LTI systems.

Alternatively, to define MIMO transfer functions using tf, you need two cell arrays (say, N and D) to represent the sets of numerator and denominator polynomials, respectively. See Structures and Cell Arrays in the MATLAB documentation for more details on cell arrays.

For example, for the rational transfer matrix , the two cell arrays N and D should contain the row-vector representations of the polynomial entries of

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)

These commands result in

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.

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 Creating Discrete-Time Models.

SISO Zero-Pole-Gain Models

Continuous-time SISO zero-pole-gain models are of the form

where is a real- or complex-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:

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:

  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);

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).

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

For example, typing

Z = {[],-5;[1-i 1+i] []};

P = {0,[-1 -1];[1 2 3],[]};

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

This produces a 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.

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)

This command results in

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

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 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. They are of the form

The Control System Toolbox software supports descriptor systems with a nonsingular matrix. The function dss is the counterpart of ss for descriptor state-space models. The syntax

sys = dss(A,B,C,D,E)

creates a continuous-time DSS model with matrix data A,B,C,D,E. For example, consider the dynamic model

with vector of angular velocities. If the inertia matrix is poorly conditioned with respect to inversion, you can specify this system as a descriptor model by

sys = dss(-F,eye(n),eye(n),0,J) 
% n = length of vector 

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][1].

For example, suppose the frequency response function for the SISO system you want to model is G(w). Suppose, in addition, that you perform an experiment to evaluate G(w) at a fixed set of frequencies, . You can do this by driving the system with a sequence of sinusoids at each of these frequencies, as depicted below.

Here is the input frequency of each sinusoid, i = 1 ... n, and G(w) = . The steady state output response of this system satisfies

A frequency response data (FRD) object is a model form you can use to store frequency response data (complex frequency response, along with a corresponding vector of frequency points) that you obtain either through simulations or experimentally. In this example, the frequency response data is obtained from the set of response pairs: .

Once you store your data in an FRD model, you can treat it as an LTI model, and manipulate an FRD model in most of the same ways you manipulate TF, SS, and ZPK models.

The basic syntax for creating a SISO FRD model is

sys = frd(response,frequencies,units)

where

For example, the MAT-file LTIexamples.mat contains a frequency vector freq, and a corresponding complex frequency response data vector respG. To load this frequency-domain data and construct an FRD model, type

load LTIexamples
sys = frd(respG,freq)

Continuous-time frequency response with 1 output and 1 input
at 5 frequency points.

From input 1 to: 
Frequency(rad/s)        output 1     
----------------        --------     
        1        -0.812505 -0.000312i
        2        -0.092593 -0.462963i
        4        -0.075781 -0.001625i
        5        -0.043735 -0.000390i

The syntax for creating a MIMO FRD model is the same as for the SISO case, except that response is a p-by-m-by-Nf multidimensional array, where p is the number of outputs, m is the number of inputs, and Nf is the number of frequency data points (the length of frequency).

The following table summarizes the complex-valued response data format for FRD models.

Data Format for the Argument Response in FRD Models

Model Structure

Response Data Format

SISO model

Vector of length Nf for which response(i) is the frequency response at the frequency frequency(i)

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-...-by-Sn multidimensional array, for which response(i,j,k,:) specifies the array of frequency response data from input j to output i at frequency frequency(k)

Creating Discrete-Time Models

Creating discrete-time models is very much like creating continuous-time models, except that you must also specify a sampling period or sample time for discrete-time models. The sample time value should be scalar and expressed in seconds. You can also use the value -1 to leave the sample time unspecified.

To specify discrete-time LTI models using tf, zpk, ss, or frd, simply append the desired sample time value Ts to the list of inputs.

sys1 = tf(num,den,Ts)
sys2 = zpk(z,p,k,Ts)
sys3 = ss(a,b,c,d,Ts)
sys4 = frd(response,frequency,Ts)

For example,

h = tf([1 -1],[1 -0.5],0.1)

creates the discrete-time transfer function with sample time 0.1 seconds, and

sys = ss(A,B,C,D,0.5)

specifies the discrete-time state-space model

with sampling period 0.5 second. The vectors denote the values of the state, input, and output vectors at the nth sample.

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

If you forget to specify the sample time when creating your model, you can still set it to the correct value by reassigning the LTI property Ts. See Sample Time for more information on setting this property.

Discrete-Time TF and ZPK Models

You can specify discrete-time TF and ZPK models using tf and zpk as indicated above. Alternatively, it is often convenient to specify such models by:

  1. Defining the variable z as a particular discrete-time TF or ZPK model with the appropriate sample time

  2. Entering your TF or ZPK model directly as a rational expression in z.

This approach parallels the procedure for specifying continuous-time TF or ZPK models using rational expressions. This procedure is described in SISO Transfer Function Models and SISO Zero-Pole-Gain Models.

For example,

z = tf('z', 0.1);
H = (z+2)/(z^2 + 0.6*z + 0.9);

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)
 
      (z^2 + 0.2z + 0.1)
 #2:  ------------------
          (z+0.1)^2
 
Sampling time: 0.1

Note that:

Discrete Transfer Functions in DSP Format

In digital signal processing (DSP), it is customary to write discrete transfer functions as rational expressions in and to order the numerator and denominator coefficients in ascending powers of . For example, the numerator and denominator of

would be specified as the row vectors [1 0.5] and [1 2 3], respectively. When the numerator and denominator have different degrees, this convention clashes with the "descending powers of " convention assumed by tf (see Transfer Function Models, or tf). For example,

h = tf([1 0.5],[1 2 3])

produces the transfer function

which differs from by a factor .

To avoid such convention clashes, you can use a separate function filt dedicated to the DSP-like specification of transfer functions. Its syntax is

h = filt(num,den)

for discrete transfer functions with unspecified sample time, and

h = filt(num,den,Ts)

to further specify the sample time Ts. This function creates TF objects just like tf, but expects num and den to list the numerator and denominator coefficients in ascending powers of . For example, typing

h = filt([1 0.5],[1 2 3])

produces

Transfer function:
   1 + 0.5 z^-1
-------------------
1 + 2 z^-1 + 3 z^-2
 
Sampling time: unspecified

You can also use filt to specify MIMO transfer functions in . Just as for tf, the input arguments num and den are then cell arrays of row vectors of appropriate dimensions (see Transfer Function Models for details). Note that each row vector should comply with the "ascending powers of " convention.

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.

[num,den,Ts] = tfdata(sys)    % Ts = sample time
[z,p,k,Ts] = zpkdata(sys)
[a,b,c,d,Ts] = ssdata(sys)
[a,b,c,d,e,Ts] = dssdata(sys)
[response,frequency,Ts] = frdata(sysfr)

Note that:

You can use any variable names you want in the output argument list of any of these functions.

The output arguments num and den assigned to tfdata, and z and p assigned to zpkdata, are cell arrays, even in the SISO case. These cell arrays have as many rows as outputs, as many columns as inputs, and their ijth entry specifies the transfer function from the jth input to the ith output. For example,

H = [tf([1 -1],[1 2 10]) , tf(1,[1 0])]

creates the one-output/two-input transfer function

Typing

[num,den] = tfdata(H);
num{1,1}, den{1,1}

displays the coefficients of the numerator and denominator of the first input channel.

ans =
     0     1    -1
ans =
     1     2    10

Note that the same result is obtained using

H.num{1,1}, H.den{1,1}

See Direct Property Referencing Using Dot Notation for more information about this syntax.

To obtain the numerator and denominator of SISO systems directly as row vectors, use the syntax

[num,den,Ts] = tfdata(sys,'v')

For example, typing

sys = tf([1 3],[1 2 5]);
[num,den] = tfdata(sys,'v')

produces

num =
 
     0     1     3

den =
 
     1     2     5

Similarly,

[z,p,k,Ts] = zpkdata(sys,'v')

returns the zeros, z, and the poles, p, as vectors for SISO systems.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS