Create transfer function model, convert to transfer function model
sys
= tf(Numerator
,Denominator
) sys
= tf(Numerator
,Denominator
,Ts
) sys
= tf(M
) sys
= tf(Numerator
,Denominator
,ltisys
) tfsys
=
tf(sys
)
tfsys = tf(sys,
'measured')
tfsys = tf(sys, 'noise')
tfsys = tf(sys, 'augmented')
Use tf
to create real or complexvalued
transfer function models (TF objects) or to convert statespace or
zeropolegain models to transfer function form. You can also use tf
to
create generalized statespace (genss
)
models or uncertain statespace (uss
)
models.
creates a continuoustime transfer function with numerator(s) and
denominator(s) specified by sys
= tf(Numerator
,Denominator
) Numerator
and Denominator
.
The output sys
is:
A tf
model object, when Numerator
and Denominator
are
numeric arrays.
A generalized statespace model (genss
)
when Numerator
or Denominator
include
tunable parameters, such as realp
parameters
or generalized matrices (genmat
).
An uncertain statespace model (uss
)
when Numerator
or Denominator
are
uncertain (requires Robust Control Toolbox™ software).
In the SISO case, Numerator
and Denominator
are
the real or complexvalued 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:
Concatenate SISO tf
models.
Use the tf
command with cell
array arguments. In this case, Numerator
and Denominator
are
cell arrays of row vectors with as many rows as outputs and as many
columns as inputs. The row vectors Numerator{i,j}
and Denominator{i,j}
specify
the numerator and denominator of the transfer function from input j
to
output i
.
For examples of creating MIMO transfer functions, see Examples and MIMO Transfer Functions in the Control System Toolbox™ User Guide.
If all SISO entries of a MIMO transfer
function have the same denominator, you can set denominator
to
the row vector representation of this common denominator. See "Examples"
for more details.
creates a discretetime transfer function with sample time sys
= tf(Numerator
,Denominator
,Ts
) Ts
(in
seconds). Set Ts = 1
to leave the sample time
unspecified. The input arguments Numerator
and Denominator
are
as in the continuoustime case and must list the numerator and denominator
coefficients in descending powers of z.
creates a static gain sys
= tf(M
) M
(scalar
or matrix).
creates a transfer function with properties inherited from the dynamic
system model sys
= tf(Numerator
,Denominator
,ltisys
) 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.
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(Numerator,Denominator,'Property1',Value1,...,'PropertyN',ValueN)
is a shortcut for
sys = tf(Numerator,Denominator) set(sys,'Property1',Value1,...,'PropertyN',ValueN)
You can also use real or complexvalued rational expressions to create a TF model. To do so, first type either:
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 discretetime 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
.
converts the dynamic
system model tfsys
=
tf(sys
) 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
, tunableTF
,
or tunableSS
model, the resulting
transfer function tfsys
takes the current values
of the tunable components.
An identified model is represented by an inputoutput 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]
.
Tip
An identified nonlinear model cannot be converted into a transfer
function. Use linear approximation functions such as 
You can use the syntax:
gensys = tf(Numerator,Denominator)
to create a Generalized statespace (genss
)
model when one or more of the entries Numerator
and Denominator
depends
on a tunable realp
or genmat
model. For more information about
Generalized statespace models, see Models with Tunable Coefficients.
Create the following transfer function model:
The model has an input current and two outputs, torque and angular velocity.
Specify the numerator and denominator coefficients of the model:
Numerator = {[1 1] ; 1}; Denominator = {[1 2 2] ; [1 0]};
Create the transfer function model, specifying the input name, output names, and variable.
H = tf(Numerator,Denominator,'InputName','current',... 'OutputName',{'torque' 'ang. velocity'},... 'Variable','p')
H = From input "current" to output... p + 1 torque:  p^2 + 2 p + 2 1 ang. velocity:  p Continuoustime transfer function.
Setting the Variable
property of the model to 'p'
causes the result to display as a transfer function of the variable p.
To use a rational expression to create a SISO transfer function model, first specify s
as a tf
object.
s = tf('s');
Create a transfer function using s
in a rational expression.
H = s/(s^2 + 2*s + 10);
This method produces the same transfer function as:
h = tf([1 0],[1 2 10]);
Create a tf
model that represents a secondorder system with known natural frequency and damping ratio.
The transfer function of a secondorder system, expressed in terms of its damping ratio and natural frequency , is:
Represent this transfer function in MATLAB using the tf
command. For example, suppose you have a system with
= 0.25 and
= 3 rad/s.
zeta = 0.25; w0 = 3; H = tf(w0^2,[1,2*zeta*w0,w0^2])
H = 9  s^2 + 1.5 s + 9 Continuoustime transfer function.
Examine the response of this transfer function to a step input.
stepplot(H)
The plot shows the ringdown expected of a secondorder system with a low damping ratio.
Create a transfer function for the discretetime, multiinput, multioutput model:
with sample time Ts = 0.2
seconds.
Specify the numerator coefficients as a 2by2 matrix.
Numerators = {1 [1 0];[1 2] 3};
Specify the coefficients of the common denominator as a row vector.
Denominator = [1 0.3];
Create the discretetime transfer function model.
Ts = 0.2; H = tf(Numerators,Denominator,Ts);
Compute the transfer function of the following statespace model:
Specify the statespace model.
sys = ss([2 1;1 2],[1 1;2 1],[1 0],[0 1]);
Convert this model to a transfer function.
tf(sys)
ans = From input 1 to output: s  4.441e16  s^2 + 4 s + 5 From input 2 to output: s^2 + 5 s + 8  s^2 + 4 s + 5 Continuoustime transfer function.
You can use a for
loop to specify an array of SISO transfer function models.
Preallocate the array with zero transfer functions.
H = tf(zeros(1,1,10));
The first two indices represent the number of outputs and inputs for the models, while the third index is the number of models in the array.
Create the transfer function models.
s = tf('s'); for k = 1:10 H(:,:,k) = k/(s^2+s+k); end
This example shows how to create a lowpass filter with one tunable parameter a:
You cannot use tunableTF
to represent F
, because the numerator and denominator coefficients of a tunableTF
block are independent. Instead, construct F
using the tunable real parameter object realp
.
Create a tunable real parameter with an initial value of 10
.
a = realp('a',10);
Use tf
to create thetunable 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 control system models. For example, see Control System with Tunable Components.
Extract the measured and noise components of an identified polynomial model into two separate transfer functions (requires System Identification Toolbox™). The measured component can serve as a plant model, while the noise component 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') sysNoise = tf(sys, 'noise')
Alternatively, use can simply use tf(sys)
to
extract the measured component.
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,
$$h\left(z\right)=\frac{{z}^{2}}{{z}^{2}+2z+3}.$$
The polynomials z^{2} 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
$$h\left({z}^{1}\right)=\frac{1}{1+2{z}^{1}+3{z}^{2}}$$
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 

 Use the row vector 
 Use the row vector 
For example,
g = tf([1 1],[1 2 3],0.1);
specifies the discrete transfer function
$$g\left(z\right)=\frac{z+1}{{z}^{2}+2z+3}$$
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
$$h\left({z}^{1}\right)=\frac{1+{z}^{1}}{1+2{z}^{1}+3{z}^{2}}=zg\left(z\right).$$
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
Numerator = [0 1 1]; Denominator = [1 2 3];
for g
(the numerator is padded with zeros
on the left) and the values
Numerator = [1 1 0]; Denominator = [1 2 3];
for h
(the numerator is padded with zeros
on the right).
tf
objects have the following properties:

Transfer function numerator coefficients. For SISO transfer functions, For MIMO transfer functions with 

Transfer function denominator coefficients. For SISO transfer functions, For MIMO transfer functions with 

Transfer function display variable, specified as one of the following:
The value of Default: 

Transport delays. For continuoustime systems, specify transport delays in the
time unit stored in the For a MIMO system with Default: 

Input delay for each input channel, specified as a scalar value
or numeric vector. For continuoustime systems, specify input delays
in the time unit stored in the For a system with You can also set Default: 0 

Output delays. For a system with Default: 0 for all output channels 

Sample time. For continuoustime models, Changing this property does not discretize or resample the model.
Use Default: 

Units for the time variable, the sample time
Changing this property has no effect on other properties, and
therefore changes the overall system behavior. Use Default: 

Input channel names, specified as one of the following:
Alternatively, use automatic vector expansion to assign input
names for multiinput models. For example, if sys.InputName = 'controls'; The input names automatically expand to You can use the shorthand notation Input channel names have several uses, including:
Default: 

Input channel units, specified as one of the following:
Use Default: 

Input channel groups. The sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5]; creates input groups named sys(:,'controls') Default: Struct with no fields 

Output channel names, specified as one of the following:
Alternatively, use automatic vector expansion to assign output
names for multioutput models. For example, if sys.OutputName = 'measurements'; The output names automatically expand to You can use the shorthand notation Output channel names have several uses, including:
Default: 

Output channel units, specified as one of the following:
Use Default: 

Output channel groups. The sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5]; creates output groups named sys('measurement',:) Default: Struct with no fields 

System name, specified as a character vector. For example, Default: 

Any text that you want to associate with the system, specified
as a character vector or cell array of character vectors. For example, Default: 

Any type of data you want to associate with system, specified as any MATLAB^{®} data type. Default: 

Sampling grid for model arrays, specified as a data structure. For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables. Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array. For example, suppose you create a 11by1
array of linear models, sysarr.SamplingGrid = struct('time',0:10) Similarly, suppose you create a 6by9
model array, [zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w) When you display M M(:,:,1,1) [zeta=0.3, w=5] = 25  s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25  s^2 + 3.5 s + 25 ... For model arrays generated by linearizing a Simulink^{®} model
at multiple parameter values or operating points, the software populates Default: 