Lesson 7
1 Learning Objectives
By the end of this lesson students will be able to:
- Convert a transfer function to state space and vice versa
- Convert a transfer function to a DE and vice versa
- In Matlab, go to Add-Ons, search for Control Systems Toolbox, and install it.
2 Where We Are
The state-space representation (SSR) is powerful because it can model a wider range of systems than the classical approach that uses transfer functions. However, transfer functions provide great insight into system behavior, so it would be useful if we could convert from SSR to transfer functions and vice versa.
3 Converting from SSR to TF
There are two ways:
- Linear algebra
- MATLAB function
ss2tf()
3.1 Linear Algebra
Remember that the SSR looks like this:
If we take the LaPlace transform of these two equations and combine them, we get the following formula:
In this equation, is the identity matrix. It can vary in size and has 1โs in the diagonal. A 3ร3 identity matrix looks like:
If we re-arrange the above equation a little, we get:
Which is a transfer function. So, to convert SSR to a transfer function, use the above formula.
3.2 Example 1
The SSR for Example 1 from last class is written below. Convert it to a transfer function using the linear algebra method.
syms s r l c1 c2
A=[-1/(r*c1) -1/(r*c1) 1/c1; -1/(r*c2) -1/(r*c2) 0; -1/l 0 0]
B=[1/(r*c1); 1/(r*c2); 1/l]
C=[0 1 0]
I=eye(3);
D=0;
ans = C*inv(s*I-A)*B+D;
simplify(ans)3.3 Student Example 1
The SSR for Student Example 1 from last class is written below. Convert it to a transfer function using the linear algebra method.
3.4 MATLAB Function
The Control Systems toolbox in MATLAB contains the function ss2tf() that will perform the conversion.
- The
ss2tf()function does not work with variables. You must assign numbers to all , , , or mass, , and values.
3.5 Example 2
Repeat Example 1 using ss2tf().
c1=1; c2=1; r=1; l=1;
A=[-1/(r*c1) -1/(r*c1) 1/c1; -1/(r*c2) -1/(r*c2) 0; -1/l 0 0]
B=[1/(r*c1); 1/(r*c2); 1/l]
C=[0 1 0]
D=0;
[num,den]=ss2tf(A,B,C,D)
vpa(num,6)
vpa(den,6)Hereโs the output I get:
num = 0 1.0000 0.0000 -0.0000
den = 1.0000 2.0000 1.0000 1.0000Is this true? Use vpa() to check:
ans = [0, 1.0, 8.55104e-16, -5.99589e-17]
ans = [1.0, 2.0, 1.0, 1.0]Looks good. But how do we translate those numbers into a transfer function like weโre used to seeing?
3.6 Student Example 2
Repeat Student Example 1 using ss2tf(). Assume , and .
4 Converting from TF to SSR
What if weโre given a transfer function and want to calculate the state-space representation? No problem, but remember:
- The state-space representation (SSR) you calculate from a transfer function will not be the same SSR you get if you start with the physical system and derive it yourself.
Does this matter? Not as long as you keep in mind that both transfer functions are still โcorrectโ; they will give the same outputs for a given input. There is another important thing to remember:
- You will not know what the state variables represent when you go from TF to SSโthey will still be valid state variables, but they will be abstract.
As before, there are two ways to convert TF to SSR:
- The canonical method
- MATLAB function
tf2ss()
4.1 Example 3
Given a transfer function for a system shown below, convert to SSR using the canonical method.
4.2 Student Example 3
Given a transfer function for a system shown below, convert to SSR using the canonical method.
4.3 Example 4
Given the transfer function below, use tf2ss() in MATLAB to convert to SSR.
num=[1 7 2];
den=[1 9 26 24];
[A,B,C,D]=tf2ss(num,den)4.4 Student Example 4
Given the transfer function below, use tf2ss() in MATLAB to convert to SSR.
5 Converting the TF to a DE and Vice Versa
The transfer function is just a LaPlace transform of a differential equation written in a non-standard way.
5.1 Example 5
Given the transfer function below, convert it to a differential equation.
5.2 Student Example 5
Convert the differential equation below to a transfer function.