In this post, and in the accompanying video tutorial, we explain how to convert state-space models into transfer functions. We explain how to perform this conversion analytically and in MATLAB. The YouTube video tutorial accompanying this post is given below.
Consider the following state-space model
(1)
where
Our goal is to convert this state-space model to a transfer function (also called a transfer matrix, since the system has multiple inputs and outputs): the transfer function will have the following form
(2)
where
Let us apply the Laplace transform to our original system (1). Since transfer functions are defined for zero initial conditions, we have to keep this fact in account while applying the Laplace transform. As the result, from (1), we obtain
(3)
where
(4)
where
(5)
where
(6)
The last equation can be written compactly
(7)
where
(8)
In the case of single-input-single-output systems, the transfer function is not a matrix, and we can write
(9)
Problem: Find the transfer function of the following system
(10)
Solution:
First, we compute
(11)
The inverse matrix
(12)
where
(13)
Consequently, the adjugate matrix is
(14)
The determinant of the matrix
Finally, our transfer function matrix is:
(15)
Below are the MATLAB codes for computing the transfer function. There are two approaches. Here is the first approach that relies upon the MATLAB Symbolic Toolbox.
% first approach for calculating the transfer function
syms s
A=[0 1 0;
0 0 1;
-1 -2 -3];
B=[10; 0; 0];
C=[1 0 0]
matrix1=s*eye(3)-A
matrix2=inv(matrix1)
transferFunction=C*matrix2*B
The command syms is used to define a symbolic complex variable
The second approach is given below. This approach relies upon the MATLAB Control System Toolbox.
% second approach for calculating the transfer function
clear, pack, clc
A=[0 1 0;
0 0 1;
-1 -2 -3];
B=[10; 0; 0];
C=[1 0 0];
D=[]
system1=ss(A,B,C,D)
transferFunction=tf(system1)
We define the state-space model by using the MATLAB function ss(). Then we transform such a state-space model into a transfer function form by using the command tf().
Below is the step response of the system computed by using the MATLAB function step().