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 Basic Models (Control System Toolbox).

A transfer function (TF) relates a particular input/output pair. For example, if
*u*(*t*) is a plant input and
*y*(*t*) is an output, the transfer function relating
them might be:

$$\frac{Y(s)}{U(s)}=G(s)=\frac{s+2}{{s}^{2}+s+10}{e}^{-1.5s}$$

This TF consists of a *numerator* polynomial, *s*+2, a
*denominator* polynomial,
*s ^{2}*+

`tf`

function:```
Gtf1 = tf([1 2], [1 1 10],'OutputDelay',1.5)
```

Transfer function: s + 2 exp(-1.5*s) * ------------ s^2 + s + 10

Like the TF format, the zero/pole/gain (ZPK) format relates an input/output pair. The difference is that the ZPK numerator and denominator polynomials are factored, as in

$$G(s)=2.5\frac{s+0.45}{(s+0.3)(s+0.1+0.7i)(s+0.1-0.7i)}$$

(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);

The state-space format is convenient if your model is a set of LTI differential and algebraic equations. For example, consider the following linearized model of a continuous stirred-tank reactor (CSTR) involving an exothermic (heat-generating) reaction [1].

$$\frac{d{{C}^{\prime}}_{A}}{dt}={a}_{11}{{C}^{\prime}}_{A}+{a}_{12}{T}^{\prime}+{b}_{11}{{T}^{\prime}}_{c}+{b}_{12}{{C}^{\prime}}_{Ai}$$

$$\frac{d{T}^{\prime}}{dt}={a}_{21}{{C}^{\prime}}_{A}+{a}_{22}{T}^{\prime}+{b}_{21}{{T}^{\prime}}_{c}+{b}_{22}{{C}^{\prime}}_{Ai}$$

where *C _{A}* is the concentration of a key
reactant,

**CSTR Schematic**

Measurement of reactant concentrations is often difficult, if not impossible. Let us
assume that *T* is a measured output,
*C _{A}* is an unmeasured output,

The model fits the general state-space format

$$\frac{dx}{dt}=Ax+Bu$$

$$y=Cx+Du$$

where

$$x=\left[\begin{array}{c}{{C}^{\prime}}_{A}\\ {T}^{\prime}\end{array}\right]\text{,}u=\left[\begin{array}{c}{{T}^{\prime}}_{c}\\ {{C}^{\prime}}_{Ai}\end{array}\right]\text{,}y=\left[\begin{array}{c}{T}^{\prime}\\ {{C}^{\prime}}_{A}\end{array}\right]$$

$$A=\left[\begin{array}{cc}{a}_{11}& {a}_{12}\\ {a}_{21}& {a}_{22}\end{array}\right]\text{,}B=\left[\begin{array}{cc}{b}_{11}& {b}_{12}\\ {b}_{21}& {b}_{22}\end{array}\right]\text{,}C=\left[\begin{array}{cc}0& 1\\ 1& 0\end{array}\right]\text{,}D=\left[\begin{array}{cc}0& 0\\ 0& 0\end{array}\right]$$

The following code shows how to define such a model for some specific values of the
*a _{ij}* and

A = [-0.0285 -0.0014 -0.0371 -0.1476]; B = [-0.0850 0.0238 0.0802 0.4462]; C = [0 1 1 0]; D = zeros(2,2); CSTR = ss(A,B,C,D);

This defines a *continuous-time* state-space model. If you do not
specify a sampling period, a default sampling value of zero applies. You can also specify
discrete-time state-space models. You can specify delays in both continuous-time and
discrete-time models.

In the CSTR example, the *D* matrix is zero and 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 model could include direct feedthrough from
the unmeasured disturbance, *C _{Ai}*, to either

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.

The following code sets some of the `CSTR`

model's optional
properties:

CSTR.InputName = {'T_c','C_A_i'}; CSTR.OutputName = {'T','C_A'}; CSTR.StateName = {'C_A','T'}; CSTR.InputGroup.MV = 1; CSTR.InputGroup.UD = 2; CSTR.OutputGroup.MO = 1; CSTR.OutputGroup.UO = 2; CSTR

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 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:

A = C_A T C_A -0.0285 -0.0014 T -0.0371 -0.1476 B = T_c C_Ai C_A -0.085 0.0238 T 0.0802 0.4462 C = C_A T T 0 1 C_A 1 0 D = T_c C_Ai T 0 0 C_A 0 0 Input groups: Name Channels MV 1 UD 2 Output groups: Name Channels MO 1 UO 2 Continuous-time model

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.

**General Case. **As mentioned in 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).

For model `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`

.

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 |
---|---|

`dcgain(CSTR)` | Calculate gain matrix for the |

`impulse(CSTR)` | Graph |

`linearSystemAnalyzer(CSTR)` | Open the Linear System Analyzer with the |

`pole(CSTR)` | Calculate |

`step(CSTR)` | Graph |

`zero(CSTR)` | Compute |

[1] Seborg, D. E., T. F. Edgar, and D. A. Mellichamp,
*Process Dynamics and Control*, 2nd Edition, Wiley, 2004, pp. 34–36
and 94–95.

`setmpcsignals`

| `ss`

| `tf`

| `zpk`