Construct Linear Time Invariant Models
Model Predictive Control Toolbox™ software supports the same LTI model formats as does Control System Toolbox™ software. You can use whichever is most convenient for your application and convert from one format to another. For more details, see Numeric Linear Time-Invariant Models.
Transfer Function Models
A transfer function (TF) relates a particular input/output pair of (possibly vector) signals. For example, if u(t) is a plant input and y(t) is an output, the transfer function relating them might be:
This TF consists of a numerator polynomial, s+2, a
denominator polynomial,
s2+s+10, and a delay,
which is 1.5 time units here. You can define G using Control System Toolbox
tf
function:
Gtf1 = tf([1 2], [1 1 10],'OutputDelay',1.5)
Transfer function: s + 2 exp(-1.5*s) * ------------ s^2 + s + 10
Zero/Pole/Gain Models
Like the TF format, the zero/pole/gain (ZPK) format relates an input/output pair of (possibly vector) signals. The difference is that the ZPK numerator and denominator polynomials are factored, as in
(zeros and/or poles are complex numbers in general).
You define the ZPK model by specifying the zero(s), pole(s), and gain as in
poles = [-0.3, -0.1+0.7*i, -0.1-0.7*i]; Gzpk1 = zpk(-0.45,poles,2.5);
State-Space Models
The state-space format is convenient if your model is a set of LTI differential and algebraic equations.
The linearized model of a Continuously Stirred Tank Reactor (CSTR) is shown in CSTR Model. In the model, the first two state variables are the concentration of reagent (here referred to as CA and measured in kmol/m3) and the temperature of the reactor (here referred to as T, measured in K), while the first two inputs are the coolant temperature (Tc, measured in K, used to control the plant), and the inflow feed reagent concentration CAf, measured in kmol/m3, (often considered as unmeasured disturbance).
A state-space model can be defined as follows:
A = [ -5 -0.3427; 47.68 2.785]; B = [ 0 1 0.3 0]; C = [0 1 1 0]; D = zeros(2,2); CSTR = ss(A,B,C,D);
This defines a continuous-time state-space model stored in the
variable CSTR
. The model is continuous time because no sampling time was
specified, and therefore a default sampling value of zero (which means that the model is
continuous time) is assumed. You can also specify discrete-time state-space models. You can
specify delays in both continuous-time and discrete-time models.
LTI Object Properties
The ss
function in the last line of the above code creates a
state-space model, CSTR
, which is an LTI object. The
tf
and zpk
commands described in Transfer Function Models and Zero/Pole/Gain Models also create
LTI objects. Such objects contain the model parameters as well as optional
properties.
Additional LTI Input and Output Properties
The following code sets some optional input and outputs names and properties for the
CSTR
state-space object:
CSTR.InputName = {'T_c', 'C_A_f'}; % set names of input signals CSTR.OutputName = {'T', 'C_A'}; % set names of output signals CSTR.StateName = {'C_A', 'T'}; % set names of state variables % assign input and output signals to different MPC categories CSTR=setmpcsignals(CSTR,'MV',1,'UD',2,'MO',1,'UO',2)
The first three lines specify labels for the input, output and state variables. The
next four specify the signal type for each input and output. The designations
MV
, UD
, MO
, and
UO
mean manipulated variable,
unmeasured disturbance, measured output, and
unmeasured output. (See MPC Signal Types for definitions.)
For example, the code specifies that input 2 of model CSTR
is an
unmeasured disturbance. The last line causes the LTI object to be displayed, generating
the following lines in the MATLAB® Command Window:
CSTR = A = C_A T C_A -5 -0.3427 T 47.68 2.785 B = T_c C_A_f C_A 0 1 T 0.3 0 C = C_A T T 0 1 C_A 1 0 D = T_c C_A_f T 0 0 C_A 0 0 Input groups: Name Channels Manipulated 1 Unmeasured 2 Output groups: Name Channels Measured 1 Unmeasured 2 Continuous-time state-space model.
Input and Output Names
The optional InputName
and OutputName
properties
affect the model displays, as in the above example. The software also uses the
InputName
and OutputName
properties to label plots
and tables. In that context, the underscore character causes the next character to be
displayed as a subscript.
Input and Output Types
As mentioned in MPC Signal Types, Model Predictive Control Toolbox software supports three input types and two output types. In a Model Predictive Control Toolbox design, designation of the input and output types determines the controller dimensions and has other important consequences.
For example, suppose your plant structure were as follows:
Plant Inputs | Plant Outputs |
---|---|
Two manipulated variables (MVs) | Three measured outputs (MOs) |
One measured disturbance (MD) | Two unmeasured outputs (UOs) |
Two unmeasured disturbances (UDs) |
The resulting controller has four inputs (the three MOs and the MD) and two outputs (the MVs). It includes feedforward compensation for the measured disturbance, and assumes that you wanted to include the unmeasured disturbances and outputs as part of the regulator design.
If you didn't want a particular signal to be treated as one of the above types, you could do one of the following:
Eliminate the signal before using the model in controller design.
For an output, designate it as unmeasured, then set its weight to zero.
For an input, designate it as an unmeasured disturbance, then define a custom state estimator that ignores the input.
Note
By default, the software assumes that unspecified plant inputs are manipulated variables, and unspecified outputs are measured. Thus, if you didn't specify signal types in the above example, the controller would have four inputs (assuming all plant outputs were measured) and five outputs (assuming all plant inputs were manipulated variables).
Note
Since the D matrix is zero, the output does not instantly respond to change in the input. The Model Predictive Control Toolbox software prohibits direct (instantaneous) feedthrough from a manipulated variable to an output. For example, the CSTR state-space model could include direct feedthrough from the unmeasured disturbance, CAf, to either CA or T but direct feedthrough from Tc to either (measured or not) output would violate this restriction. When the model has a direct feedthrough from Tc, you can add a small delay at this input to circumvent the problem.
For CSTR
, the default Model Predictive Control Toolbox assumptions are incorrect. You must set its InputGroup
and OutputGroup
properties, as illustrated in the above code, or modify
the default settings when you load the model into MPC Designer.
Use setmpcsignals
to make type definition. For example:
CSTR = setmpcsignals(CSTR,'UD',2,'UO',2);
sets InputGroup
and OutputGroup
to the same
values as in the previous example. The CSTR
display would then include
the following lines:
Input groups: Name Channels Unmeasured 2 Manipulated 1 Output groups: Name Channels Unmeasured 2 Measured 1
Notice that setmpcsignals
sets unspecified inputs to
Manipulated
and unspecified outputs to
Measured
.
LTI Model Characteristics
Control System Toolbox software provides functions for analyzing LTI models. Some of the more
commonly used are listed below. Type the example code at the MATLAB prompt to see how they work for the CSTR
example.
Example | Intended Result |
---|---|
damp(CSTR) | Displays the damping ratio, natural frequency, and time constant of the poles
of CSTR . |
pzmap(CSTR) | Plots the poles and zeros of |
pole(CSTR) | Calculates the poles of |
tzero(CSTR) | Calculates the transmission zeros of
|
dcgain(CSTR) | Calculates the steady state gain matrix of
|
step(CSTR) | Plots unit-step responses of |
stepinfo(CSTR) | Calculates rise time, settling time, and other step-response characteristics of
CSTR . |
impulse(CSTR) | Plots the unit-impulse responses of
|
sigma(CSTR) | Plots the singular values of the frequency response of
|
bode(CSTR) | Plots the Bode frequency responses of
|
nyquist(CSTR) | Plots the Nyquist frequency responses of
|
nichols(CSTR) | Plots the Nichols frequency responses of
|
linearSystemAnalyzer(CSTR) | Opens the Linear System Analyzer with the |
See Also
Apps
Functions
tf
|zpk
|ss
|setmpcsignals