Transfer functions are a vital concept in control systems engineering. They describe the relationship between the input and output of linear time-invariant (LTI) systems using Laplace transforms. In MATLAB, we can easily create and analyze transfer function models using the built-in tf function and related functions. In this comprehensive guide, we will explore how to:
- Understand transfer functions and LTI systems
- Create SISO and MIMO transfer function models with
tf - Analyze magnitude, phase, poles, and zeros
- Simulate step and impulse responses
- Convert to and from state-space models
What is a Transfer Function?
A transfer function mathematically describes what a system does to an input signal to produce the output signal. It is defined as the ratio of the Laplace transform of the output (Y(s)) to the Laplace transform of the input (U(s)):
G(s) = Y(s)/U(s)
Where s represents the complex Laplace variable. This function fully characterizes the input-output relationship for an LTI system.
The Laplace transform allows us to analyze the system behavior and stability in the complex s-domain instead of looking at differential equations in the time domain. This makes transfer functions very useful engineering tools.
Inside the transfer function model, we have:
- Numerator coefficients – Determines the zeros (s values making TF 0)
- Denominator coefficients – Determines the poles(s values making TF undefined)
Now let‘s see this concept in action by creating transfer function models in MATLAB.
Creating Transfer Functions
The tf command allows us to generate transfer function models. The basic syntax is:
sys = tf(num, den)
Where num and den are row vectors containing polynomial coefficients.
For example:
num = [2 3];
den = [1 2 7];
sys = tf(num,den)
sys =
3 s + 2
--------------
s^2 + 2 s + 7
We can also specify additional properties like sample time:
sys_d = tf(num,den,0.1)
sys_d =
3 z + 2
-----------
z^2 + 1.8z + 6.3
Now we have a discrete-time transfer function with sampling time Ts = 0.1 sec.
For MIMO systems with multiple inputs and outputs, num and den become matrices of coefficients.
Let‘s create a 2 input, 2 output system:
num = [1 2; 3 4];
den = [5 7; 1 9];
sys = tf(num,den)
sys =
1 s + 2 3 s + 4
-------------- --------------
5 s + 7 s + 9
So with tf(), creating transfer function models of any size or type is very straightforward.
Analyzing Poles and Zeros
To analyze a transfer function further, we need to find its poles, zeros and gain. MATLAB provides several handy functions for these tasks:
Zeros
zeros(sys)
Poles
poles(sys)
Gain
dcgain(sys)
For example:
sys = tf([1 2],[1 2 7])
zeros(sys)
ans =
-2
poles(sys)
ans =
0
-1
-7
dcgain(sys)
ans =
1
This shows one zero at z = -2, three poles at p = {0, -1, -7}, and a DC gain of 1.
The zero and pole plots can graphically visualize their locations too:
zero(sys)
pole(sys)
Having this s-domain information helps us assess stability, characterize frequency response, and design controllers for the system.
Step and Impulse Responses
The step response shows the time domain output to a step input change. The impulse response describes the output to an impulse (Dirac delta) input.
We can easily simulate these responses in MATLAB with:
Step Response
step(sys)
Impulse Response
impulse(sys)
Plotting the responses gives the dynamic visualization:
step(sys)
impulse(sys)
These standard test signals analyze if the system is overdamped, underdamped, stable, etc. This is very useful analysis for control systems designers.
Converting to State-Space
While working with transfer functions, we may need to convert the system model to state-space format. State-space representation uses state variables and matrices instead of the rational transfer function.
Going from transfer function to state-space is easy in MATLAB using:
sys_ss = ss(sys)
For the reverse conversion, state-space to transfer function:
sys_tf = tf(sys_ss)
Let‘s demonstrate a conversion:
sys = tf([1],[1 2 7])
sys_ss = ss(sys)
sys_ss =
A =
0 1
0 -7
B =
0
1
C =
1 0
D =
0
sys_tf = tf(sys_ss)
sys_tf =
1
----------
s^2 + 2 s + 7
So MATLAB allows easy interconversion between equivalent system representations.
Frequency Response Analysis
Another key functionality for transfer functions is generating Bode plots to analyze the frequency response. This shows the gain and phase behavior over a range of frequencies.
The bode() function handles creating the plot:
sys = tf([1],[1 2 7])
bode(sys)
The Bode diagram enables analyzing stability margins, resonance peaks, cut-off frequencies and more. So it‘s a crucial analysis tool for control systems and filter design applications.
Advantages of Transfer Functions
Some key benefits of working with transfer function models in MATLAB are:
- Simplicity: Just define numerator and denominator coefficients
- Intuitive: Block diagram representation
- Analysis: Easily assess stability, frequency response and dynamics
- Design: Straightforward to design feedback controllers
- Interoperability: Can interface with other model types like state-space
So when dealing with linear time-invariant systems, transfer functions make modeling, simulation and control design much easier.
Conclusion
Transfer functions provide a powerful mathematical representation of LTI systems using the Laplace transform domain. In this article, we explored how to:
- Create SISO and MIMO models with the
tffunction - Find poles, zeros and gain
- Analyze step/impulse responses
- Convert between transfer function and state-space formats
- Assess frequency response characteristics with Bode plots
MATLAB simplifies working with transfer functions for control theory and signal processing applications using an intuitive set of inbuilt tools. Through some hands-on examples, we have demonstrated how to perform essential transfer function tasks programmatically.
I hope you found this guide useful! Let me know if you have any other transfer function topics you would like covered.


