Skip to Main Content Skip to Search
Product Documentation

tf - Create transfer function model, convert to transfer function model

Syntax

tf
sys = tf(num,den)
sys = tf(num,den,Ts)
sys = tf(M)
sys = tf(num,den,ltisys)
tfsys = tf(sys)
tfsys = tf(sys)
tfsys = tf(sys, 'measured')
tfsys = tf(sys, 'augmented')

Description

Use tf to create real- or complex-valued transfer function models (TF objects) or to convert state-space or zero-pole-gain models to transfer function form. You can also use tf to create Generalized state-space (genss) models.

Creation of Transfer Functions

sys = tf(num,den) creates a continuous-time transfer function with numerator(s) and denominator(s) specified by num and den. The output sys is a TF object storing the transfer function data.

In the SISO case, num and den are the real- or complex-valued row vectors of numerator and denominator coefficients ordered in descending powers of s. These two vectors need not have equal length and the transfer function need not be proper. For example, h = tf([1 0],1) specifies the pure derivative h(s) = s.

To create MIMO transfer functions, using one of the following approaches:

For examples of creating MIMO transfer functions, see Examples and MIMO Transfer Function Model in the Control System Toolbox User Guide.

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

sys = tf(M) creates a static gain M (scalar or matrix).

sys = tf(num,den,ltisys) creates a transfer function with properties inherited from the dynamic system model ltisys (including the sample time).

There are several ways to create arrays of transfer functions. To create arrays of SISO or MIMO TF models, either specify the numerator and denominator of each SISO entry using multidimensional cell arrays, or use a for loop to successively assign each TF model in the array. See Model Arrays in the Control System Toolbox User Guide for more information.

Any of the previous syntaxes can be followed by property name/property value pairs

'Property',Value

Each pair specifies a particular property of the model, for example, the input names or the transfer function variable. For information about the properties of tf objects, see Properties. Note that

sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN)

is a shortcut for

sys = tf(num,den)
set(sys,'Property1',Value1,...,'PropertyN',ValueN)

Transfer Functions as Rational Expressions in s or z

You can also use real- or complex-valued rational expressions to create a TF model. To do so, first type either:

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.

Conversion to Transfer Function

tfsys = tf(sys) converts the dynamic system model sys to transfer function form. The output tfsys is a tf model object representing sys expressed as a transfer function.

If sys is a model with tunable components, such as a genss, genmat, ltiblock.tf, or ltiblock.ss model, the resulting transfer function tfsys takes the current values of the tunable components.

Conversion of Identified Models

An identified model is represented by an input-output equation of the form y(t) = Gu(t) + He(t), where u(t) is the set of measured input channels and e(t) represents the noise channels. If Λ = LL' represents the covariance of noise e(t), this equation can also be written as: y(t) = Gu(t) + HLv(t), where cov(v(t)) = I.

tfsys = tf(sys), or tfsys = tf(sys, 'measured') converts the measured component of an identified linear model into the transfer function form. sys is a model of type idss, idproc, idtf, idpoly, or idgrey. tfsys represents the relationship between u and y. tfsys = tf(sys, 'noise') converts the noise component of an identified linear model into the transfer function form. It represents the relationship between the noise input, v(t) and output, y_noise = HL v(t). The noise input channels belong to the InputGroup 'Noise'. The names of the noise input channels are v@yname, where yname is the name of the corresponding output channel. tfsys has as many inputs as outputs.

tfsys = tf(sys, 'augmented') converts both the measured and noise dynamics into a transfer function. tfsys has ny+nu inputs such that the first nu inputs represent the channels u(t) while the remaining by channels represent the noise channels v(t). tfsys.InputGroup contains 2 input groups- 'measured' and 'noise'. tfsys.InputGroup.Measured is set to 1:nu while tfsys.InputGroup.Noise is set to nu+1:nu+ny. tfsys represents the equation y(t) = [G HL] [u; v].

Creation of Generalized State-Space Models

You can use the syntax:

gensys = tf(num,den)

to create a Generalized state-space (genss) model when one or more of the entries num and den depends on a tunable realp or genmat model. For more information about Generalized state-space models, see Models with Tunable Coefficients.

Examples

Example 1

Transfer Function Model with One-Input Two-Outputs

Create the one-input, two-output transfer function

with input current and outputs torque and ang velocity.

To do this, enter

num = {[1 1] ; 1};
den = {[1 2 2] ; [1 0]};
H = tf(num,den,'inputn','current',...
                      'outputn',{'torque' 'ang. velocity'},...
                          'variable','p')

These commands produce the result:

Transfer function from input "current" to output...
              p + 1
 torque:  -------------
          p^2 + 2 p + 2
 
                 1
 ang. velocity:  -
                 p

Setting the 'variable' property to 'p' causes the result to be displayed as a transfer function of the variable p.

Example 2

Transfer Function Model Using Rational Expression

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

Multiple-Input Multiple-Output Transfer Function Model

Specify the discrete MIMO transfer function

with common denominator d (z) = z + 0.3 and sample time of 0.2 seconds.

nums = {1 [1 0];[-1 2] 3};
Ts = 0.2;
H = tf(nums,[1 0.3],Ts)     % Note: row vector for common den. d(z)

Example 4

Convert State-Space Model to Transfer Function

Compute the transfer function of the state-space model with the following data.

To do this, type

sys = ss([-2 -1;1 -2],[1 1;2 -1],[1 0],[0 1]);
tf(sys) 

These commands produce the result:

Transfer function from input 1 to output:
s - 4.441e-016
--------------
s^2 + 4 s + 5
 
Transfer function from input 2 to output:
s^2 + 5 s + 8
-------------
s^2 + 4 s + 5

Example 5

Array of Transfer Function Models

You can use a for loop to specify a 10-by-1 array of SISO TF models.

H = tf(zeros(1,1,10)); 
s = tf('s')                                                  
for k=1:10,                                                              
		H(:,:,k) = k/(s^2+s+k);                                               
end                                                                      

The first statement pre-allocates the TF array and fills it with zero transfer functions.

Example 6

Tunable Low-Pass Filter

This example shows how to create the low-pass filter F = a/(s + a) with one tunable parameter a.

You cannot use ltiblock.tf to represent F, because the numerator and denominator coefficients of an ltiblock.tf block are independent. Instead, construct F using the tunable real parameter object realp.

  1. Create a tunable real parameter.

    a = realp('a',10);   
    

    The realp object a is a tunable parameter with initial value 10.

  2. Use tf to create the tunable filter F:

    F = tf(a,[1 a]);

F is a genss object which has the tunable parameter a in its Blocks property. You can connect F with other tunable or numeric models to create more complex models of control systems. For an example, see Control System with Tunable Components.

Example 7

Extract the measured and noise components of an identified polynomial model into two separate transfer functions. The former (measured component) can serve as a plant model while the latter can serve as a disturbance model for control system design.

load icEngine

z = iddata(y,u,0.04);
nb = 2; nf = 2; nc = 1; nd = 3; nk = 3;
sys = bj(z, [nb nc nd nf nk]);

sys is a model of the form: y(t) = B/F u(t) + C/D e(t), where B/F represents the measured component and C/D the noise component.

sysMeas = tf(sys, 'measured') % or simply tf(sys)
sysNoise = tf(sys, 'noise')

Discrete-Time Conventions

The control and digital signal processing (DSP) communities tend to use different conventions to specify discrete transfer functions. Most control engineers use the z variable and order the numerator and denominator terms in descending powers of z, for example,

The polynomials z2 and z2 + 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

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), 'q'

Use the row vector [ak ... a1 a0] to specify the polynomial (coefficients ordered in descending powers of z or q).

'z^-1'

Use the row vector [b0 b1 ... bk] to specify the polynomial (coefficients in ascending powers of z-1).

For example,

g = tf([1 1],[1 2 3],0.1);

specifies the discrete transfer function

because z is the default variable. In contrast,

h = tf([1 1],[1 2 3],0.1,'variable','z^-1');

uses the DSP convention and creates

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

Properties

tf objects have the following properties:

num

Transfer function numerator coefficients.

For SISO transfer functions, num is a row vector of polynomial coefficients in order of descending power (for Variable values s, z, p, or q) or in order of ascending power (for Variable values z^-1 or q^-1).

For MIMO transfer functions with Ny outputs and Nu inputs, num is a Ny-by-Nu cell array of the numerator coefficients for each input/output pair.

den

Transfer function denominator coefficients.

For SISO transfer functions, den is a row vector of polynomial coefficients in order of descending power (for Variable values s, z, p, or q) or in order of ascending power (for Variable values z^-1 or q^-1).

For MIMO transfer functions with Ny outputs and Nu inputs, den is a Ny-by-Nu cell array of the denominator coefficients for each input/output pair.

Variable

String specifying the transfer function display variable. Variable can take the following values:

  • 's' — Default for continuous-time models

  • 'z' — Default for discrete-time models

  • 'p' — Equivalent to 's'

  • 'q' — Equivalent to 'z'

  • 'z^-1' — Inverse of 'z'

  • 'q^-1' — Equivalent to 'z^-1'

The value of Variable is reflected in the display, and also affects the interpretation of the num and den coefficient vectors for discrete-time models. For Variable = 'z' or 'q', the coefficient vectors are ordered in descending powers of the variable. For Variable = 'z^-1' or 'q^-1', the coefficient vectors are ordered as ascending powers of the variable.

Default: 's'

ioDelay

Transport delays. ioDelay is a numeric array specifying a separate transport delay for each input/output pair.

For continuous-time systems, specify transport delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify transport delays as integers denoting delay of a multiple of the sampling period Ts.

For a MIMO system with Ny outputs and Nu inputs, set ioDelay to a Ny-by-Nu array, where each entry is a numerical value representing the transport delay for the corresponding input/output pair. You can also set ioDelay to a scalar value to apply the same delay to all input/output pairs.

Default: 0 for all input/output pairs

InputDelay

Input delays. InputDelay is a numeric vector specifying a time delay for each input channel. For continuous-time systems, specify input delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify input delays in integer multiples of the sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods.

For a system with Nu inputs, set InputDelay to an Nu-by-1 vector, where each entry is a numerical value representing the input delay for the corresponding input channel. You can also set InputDelay to a scalar value to apply the same delay to all channels.

Default: 0 for all input channels

OutputDelay

Output delays. OutputDelay is a numeric vector specifying a time delay for each output channel. For continuous-time systems, specify output delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify output delays in integer multiples of the sampling period Ts. For example, OutputDelay = 3 means a delay of three sampling periods.

For a system with Ny outputs, set OutputDelay to an Ny-by-1 vector, where each entry is a numerical value representing the output delay for the corresponding output channel. You can also set OutputDelay to a scalar value to apply the same delay to all channels.

Default: 0 for all output channels

Ts

Sampling time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sampling time, set Ts = -1.

Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sampling time of a discrete-time system.

Default: 0 (continuous time)

TimeUnit

String representing the unit of the time variable, any time delays in the model (for continuous-time models), and the sampling time Ts (for discrete-time models). TimeUnit can take the following values:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • 'seconds'

  • 'minutes'

  • 'hours'

  • 'days'

  • 'weeks'

  • 'months'

  • 'years'

Changing this property changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings.

Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter:

sys.InputName = 'controls';

The software automatically expands the input names to {'controls(1)';'controls(2)'}.

You can use the shorthand notation u to refer to the InputName property. For example, sys.u is equivalent to sys.InputName.

Input channel names have several uses, including:

  • Identifying channels on model display and plots

  • Extracting subsystems of MIMO systems

  • Specifying connection points when interconnecting models

Default: Empty string '' for all input channels

InputUnit

Input channel units. Use InputUnit to keep track of input signal units. Set InputUnit to a string for single-input model, or to a cell array of strings for a multi-input model. InputUnit has no effect on system behavior.

Default: Empty string '' for all input channels

InputGroup

Input channel groups. The InputGroup property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure whose field names are the group names and whose field values are the input channels belong to each group. For example:

sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];

creates input groups named controls and noise that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the controls inputs to all outputs using:

sys(:,'controls')

Default: Struct with no fields

OutputName

Output channel names. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings.

Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter:

sys.OutputName = 'measurements';

The software automatically expands the output names to {'measurements(1)';'measurements(2)'}.

You can use the shorthand notation y to refer to the OutputName property. For example, sys.y is equivalent to sys.OutputName.

Output channel names have several uses, including:

  • Identifying channels on model display and plots

  • Extracting subsystems of MIMO systems

  • Specifying connection points when interconnecting models

Default: Empty string '' for all input channels

OutputUnit

Output channel units. Use OutputUnit to keep track of output signal units. Set OutputUnit to a string for single-input model, or to a cell array of strings for a multi-input model. OutputUnit has no effect on system behavior.

Default: Empty string '' for all input channels

OutputGroup

Output channel groups. The OutputGroup property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure whose field names are the group names and whose field values are the output channels belong to each group. For example:

sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];

creates output groups named temperature and measurement that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the measurement outputs using:

sys('measurement',:)

Default: Struct with no fields

Name

System name. Set Name to a string to label the system.

Default: ''

Notes

Any text that you wish to associate with the system. Set Notes to a string or a cell array of strings.

Default: {}

UserData

Any type of data you wish to associate with system. Set UserData to any MATLAB data type.

Default: []

Algorithms

tf uses the MATLAB function poly to convert zero-pole-gain models, and the functions zero and pole to convert state-space models.

See Also

filt | frd | get | set | ss | tfdata | zpk

Tutorials

How To

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS