In this demo, we'll use the Control System Toolbox in MATLAB to create continuous and discrete linear time-invariant (LTI) models. The toolbox provides commands for creating four basic types of (LTI) models:
These functions take model data as input and return objects that embody this data in a single MATLAB variable.
We'll look at how easy it is to create each of the four types of LTI models. First we'll look at the commands needed to create continuous-time LTI systems. Then we'll look at how to use the same commands to create discrete-time LTI models.
where:
The numerator and denominator polynomials define a transfer function model. A vector of coefficients specifies the polynomials. For example:
[ 1, 2, 10 ]
would specify the polynomial
We will create a SISO transfer function model by specifying its numerator and denominator polynomials as inputs to the TF function:
num = [ 1 0 ]; % Numerator: s den = [ 1 2 10 ]; % Denominator: s^2 + 2 s + 10 H = tf(num,den) % Creates the LTI object and displays the result
Transfer function:
s
--------------
s^2 + 2 s + 10
We can also specify this model as a rational expression of s:
s = tf('s'); % Creates Laplace variable H = s / (s^2 + 2*s + 10) % This code creates the LTI object % and displays the result
Transfer function:
s
--------------
s^2 + 2 s + 10
where
Zero-pole-gain models are the factored form of transfer function models.In this format, the gain k, zeros z (numerator roots), and poles p (denominator roots) characterize the model.
We can specify a SISO zero-pole-gain model using the ZPK command:
z = 0; % Zeros p = [ 2 1+i 1-i ]; % Poles k = -2; % Gain H = zpk(z,p,k) % Creates the LTI object and displays the result
Zero/pole/gain:
-2 s
---------------------
(s-2) (s^2 - 2s + 2)
We can also specify this model as a rational expression of s:
s = zpk('s'); % Create Laplace variable H = -2*s / (s - 2) / (s^2 - 2*s + 2) % Creates the LTI object % and displays the result
Zero/pole/gain:
-2 s
---------------------
(s-2) (s^2 - 2s + 2)
where
We can construct state-space models from the linear differential or difference equations describing the system dynamics. The state-space matrices A, B, C, and D characterize these models.
The following describes a simple electric motor.
where
In the next illustration we can see the relationship between the driving current (input) and the angular displacement of the rotor (output) in state-space form.
Next, we'll use the SS function to create the state-space model of this system in MATLAB:
A = [ 0 1 ; -5 -2 ];
B = [ 0 ; 3 ];
C = [ 1 0 ];
D = 0;
H = ss(A,B,C,D) % Creates the LTI object and displays the result
a =
x1 x2
x1 0 1
x2 -5 -2
b =
u1
x1 0
x2 3
c =
x1 x2
y1 1 0
d =
u1
y1 0
Continuous-time model.
GSCreatingModels_aux % External function to draw diagram
Figure 1: Frequency response data models.
We use frequency response data or FRD models to store the measured or simulated complex frequency response of a system in an LTI object. We can then analyze the model using the Control System Toolbox.
Given a vector of frequencies and a vector of system responses to excitation at these frequencies,
From input 1 to:
Frequency(Hz) output 1
------------- --------
1000 -0.8126-0.0003i
2000 -0.1751-0.0016i
3000 -0.0926-0.4630iWe can construct an FRD model with this data using the FRD command:
freq = [1000 ; 2000 ; 3000]; % Measured in Hz resp = [-0.8126-0.0003i ; -0.1751-0.0016i ; -0.0926-0.4630i]; H = frd(resp,freq,'Units','Hz') % Creates the LTI FRD model % and displays the result
From input 1 to:
Frequency(Hz) output 1
------------- --------
1000 -0.8126-0.0003i
2000 -0.1751-0.0016i
3000 -0.0926-0.4630i
Continuous-time frequency response data model.
We use the last two arguments in the frd function shown to indicate that the frequency units are in Hertz.
The Control System Toolbox supports the use of both continuous-time and discrete-time models. We use a similar syntax for creating a discrete-time model as for a continuous-time model, except that we also provide a sampling time.
Sample Time = 0.1 sec
We can specify a discrete-time transfer function model by providing a sample time argument to the TF function:
num = [ 1 -1 ];
den = [ 1 -1.85 0.9 ];
H = tf(num,den,0.1); % Ts = 0.1 sec
We can also specify this model as a rational expression of z:
z = tf('z',0.1); % Ts = 0.1 sec H = (z - 1) / (z^2 - 1.85*z + 0.9);
For more information on feedback control design with the Control System Toolbox, see the Control System Toolbox product information page.
From here you can download a free 30-day trial, read the documentation and user stories, request more information, and get pricing information. See these additional demos of Control System Toolbox functionality: