Linear Time Invariant (LTI) systems in Matlab

This page will discuss only single input-single output (SISO) systems, though Matlab can handle systems with multiple inputs and multiple outputs (MIMO).   If you are interested in seeing how to apply the commands listed below to MIMO systems, use Matlabs "help" command.

Though Matlab has 3 ways to define systems (Transfer functions, State Variables, and Pole-Zero), this document on deals with Transfer Function and State Variable Representations.

Defining a system with a Transfer Function

Consider the transfer function:

wpe6B.gif (1146 bytes)

To define a system Sys1 in Matlab you could type:

» Sys1=tf([2 2],[1 3 2])
Transfer function:
2 s + 2
-------------
s^2 + 3 s + 2

This defines an "system object" which has certain properties.  To list the properties

» get(Sys1)
num = {[0 2 2]}
den = {[1 3 2]}
Variable = 's'
Ts = 0
Td = 0
InputName = {''}
OutputName = {''}
Notes = {}
UserData = []

Note that the numerator and denominator polynomials are in braces "{}".  This is to handle the MIMO case.  If you want to get the system numerator, type:

» n=Sys1.num{1}
n =
0 2 2

and likewise for the denominator.    Another way to do this is with the get function (which will return a property):

» n1=Sys1.num{1};
» n=n1{1};

You can also use the command "tfdata" to get both numerator and denominator:

» [n,d]=tfdata(Sys1,'v');

The argument 'v' is important to get the actual numerator and denominator for a SISO system.  The only other object properties that you might want to use are the InputName and OutputName.   If you assign these properties, the input name and output name will be printed on all graphs, and whenever you display the transfer function.  To name the input and   output and then display the transfer function:

» Sys1.InputName='MyInput';
»
Sys1.OutputName='MyOutput';
»
Sys1
Transfer function from input "MyInput" to output "MyOutput":
2 s + 2
-------------
s^2 + 3 s + 2


Defining a system with State Variables

Likewise a system can be defined using the state-variable representation:

» a=[0 1; -2 -3]; b=[0 1]'; c=[1 0]; d=0;
»
Sys2=ss(a,b,c,d);

To view the object properties:

» get(Sys2)
a = [2x2 double]
b = [2x1 double]
c = [1 0]
d = 0
e = []
StateName = {2x1 cell}
Ts = 0
Td = 0
InputName = {''}
OutputName = {''}
Notes = {}
UserData = []

The state variables and input and output can be named:

» Sys2.InputName='S2 In';
»
Sys2.OutputName='S2 Out';
»
Sys2.StateName={'S2 State1' 'S2 State2'};

These names appear when viewing the object:

» Sys2
a = 
             S2 State1      S2 State2
S2 State1            0              1
S2 State2           -2             -3

b = 
                  S2 In
S2 State1             0
S2 State2             1
c = 
             S2 State1      S2 State2
S2 Out               1              0
  
d = 
             S2 In
S2 Out           0

Continuous-time system.

As with the systems defined in terms of the transfer function it is possible to get the state space properties.  To get the amatrix

» amatrix=Sys2.a
amatrix =
0  1
-2 -3

or to get all matrices at one time

» [amatrix,bmatrix,cmatrix,dmatrix]=ssdata(Sys2);

Converting Between LTI Representations

Recall, from above, that Sys1 was defined in terms of the transfer function and Sys2 was defined in terms of its state-space representation:

System Characterization and Responses
    In the following, "sys" is an LTI SISO system.


 

email me with any comments on how to improve the information on this page (either presentation or content)

arrowBack