Main Content

ss

Convert unconstrained MPC controller to state-space linear system form

Description

Use the Model Predictive Control Toolbox™ ss function to convert an unconstrained MPC controller with defined sample time to state space form (see mpc for background). The returned controller is equivalent to the original MPC controller MPCobj when no constraints are active. You can then use Control System Toolbox™ software for sensitivity analysis and other diagnostic calculations.

To create or convert a generic LTI dynamical system to state space form, see ss and Dynamic System Models.

example

kss = ss(MPCobj) returns the linear discrete-time dynamic controller kss, in state-space form. kss is equivalent to the MPC controller MPCobj when no constraint is active.

kssFull = ss(MPCobj,signals) returns the linear discrete-time dynamic controller kss, in full state-space form, and allows you to specify the signals that you want to include as inputs for kssFull.

kssFullPv = ss(MPCobj,signals,refPreview,mdPreview) specifies whether the returned controller has preview action, that is if it uses the whole reference and measured disturbance sequences as input signals.

[kss,ut] = ss(MPCobj) also returns the input target values for the full form of the controller.

Examples

collapse all

Create the plant model.

plant = rss(5,2,3);
plant.D = 0;
plant = setmpcsignals(plant,'mv',1,'md',2,'ud',3,'mo',1,'uo',2);

Configure the MPC controller with a sample time of 0.1 seconds and nonzero nominal values, weights, and input targets.

mpcobj = mpc(plant,0.1);
-->The "PredictionHorizon" property is empty. Assuming default 10.
-->The "ControlHorizon" property is empty. Assuming default 2.
-->The "Weights.ManipulatedVariables" property is empty. Assuming default 0.00000.
-->The "Weights.ManipulatedVariablesRate" property is empty. Assuming default 0.10000.
-->The "Weights.OutputVariables" property is empty. Assuming default 1.00000.
   for output(s) y1 and zero weight for output(s) y2 
mpcobj.Model.Nominal.U = [0.7 0.8 0];
mpcobj.Model.Nominal.Y = [0.5 0.6];
mpcobj.Model.Nominal.DX = rand(5,1); 

mpcobj.Weights.MV = 2;
mpcobj.Weights.OV = [3 4];

mpcobj.MV.Target = [0.1 0.2 0.3];

Specifying mpcobj.Model.Nominal.DX as nonzero means that the nominal values are not at steady state mpcobj.MV.Target specifies three preview steps.

Convert mpcobj to a state-space model.

Kss = ss(mpcobj)
-->Converting model to discrete time.
-->The "Model.Disturbance" property is empty:
   Assuming unmeasured input disturbance #3 is integrated white noise.
   Assuming no disturbance added to measured output channel #1.
-->The "Model.Noise" property is empty. Assuming white noise on each measured output.

Kss =
 
  A = 
                  xMPC1       xMPC2       xMPC3       xMPC4       xMPC5
   xMPC1         0.6713     0.04207      0.1267     0.01344    -0.09876
   xMPC2        0.02215      0.7027      0.1261      0.0332    -0.08825
   xMPC3       -0.05555     -0.1095      0.7378     -0.1265      0.1711
   xMPC4       -0.05395     0.04959      0.1765      0.5649     -0.1107
   xMPC5      -0.002772    -0.01301     -0.1778    0.004795      0.7193
   xMPC6        0.09615           0     -0.1363      0.1317     0.09372
   prev.MV1     -0.6477       -0.24     -0.3161      -1.176      0.6766
 
                  xMPC6    prev.MV1
   xMPC1      -0.003895   7.095e-06
   xMPC2       -0.07105  -1.571e-05
   xMPC3        0.06713   0.0001034
   xMPC4        0.01855    0.000207
   xMPC5        0.08932  -1.435e-05
   xMPC6              1           0
   prev.MV1      0.4708    0.002093
 
  B = 
                  MO1
   xMPC1     -0.02458
   xMPC2     -0.02111
   xMPC3      0.08656
   xMPC4     -0.03556
   xMPC5      0.01104
   xMPC6      0.08828
   prev.MV1    0.1824
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1   -0.6477     -0.24   -0.3161    -1.176    0.6766    0.4708  0.002093
 
  D = 
           MO1
   MV1  0.1824
 
Sample time: 0.1 seconds
Discrete-time state-space model.

The output, sys, is a seventh-order SISO state-space model. The seven states include the five plant model states, one state from the default input disturbance model, and one state from the previous move, u(k-1).

Set mpcobj to use custom state estimation.

setEstimator(mpcobj,'custom');

Convert mpcobj to a static gain matrix for state-feedback.

K = ss(mpcobj)
-->Converting model to discrete time.
-->The "Model.Disturbance" property is empty:
   Assuming unmeasured input disturbance #3 is integrated white noise.
   Assuming no disturbance added to measured output channel #1.
-->The "Model.Noise" property is empty. Assuming white noise on each measured output.

K =
 
  D = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1   -0.8463     -0.24  -0.03447    -1.448    0.4829    0.4708  0.002093
 
Static gain.

As expected this is a row vector with seven elements.

Reset mpcobj to use the default estimator.

setEstimator(mpcobj,'default');

You can use 'rv' as a second argument to return a system with 3 additional inputs (reference of measured plant output, reference of unmeasured plant output and measured disturbance).

Kss = ss(mpcobj, 'rv')
-->Converting model to discrete time.
-->The "Model.Disturbance" property is empty:
   Assuming unmeasured input disturbance #3 is integrated white noise.
   Assuming no disturbance added to measured output channel #1.
-->The "Model.Noise" property is empty. Assuming white noise on each measured output.

Kss =
 
  A = 
                  xMPC1       xMPC2       xMPC3       xMPC4       xMPC5
   xMPC1         0.6713     0.04207      0.1267     0.01344    -0.09876
   xMPC2        0.02215      0.7027      0.1261      0.0332    -0.08825
   xMPC3       -0.05555     -0.1095      0.7378     -0.1265      0.1711
   xMPC4       -0.05395     0.04959      0.1765      0.5649     -0.1107
   xMPC5      -0.002772    -0.01301     -0.1778    0.004795      0.7193
   xMPC6        0.09615           0     -0.1363      0.1317     0.09372
   prev.MV1     -0.6477       -0.24     -0.3161      -1.176      0.6766
 
                  xMPC6    prev.MV1
   xMPC1      -0.003895   7.095e-06
   xMPC2       -0.07105  -1.571e-05
   xMPC3        0.06713   0.0001034
   xMPC4        0.01855    0.000207
   xMPC5        0.08932  -1.435e-05
   xMPC6              1           0
   prev.MV1      0.4708    0.002093
 
  B = 
                   MO1    ref.MO1    ref.UO1        MD1
   xMPC1      -0.02458  -0.004287  -0.001904   -0.07169
   xMPC2      -0.02111   0.009493   0.004217  -0.008505
   xMPC3       0.08656   -0.06251   -0.02777    0.07852
   xMPC4      -0.03556    -0.1251   -0.05557    0.02606
   xMPC5       0.01104   0.008671   0.003852  -0.006028
   xMPC6       0.08828          0          0          0
   prev.MV1     0.1824     -1.265    -0.5617       1.28
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1   -0.6477     -0.24   -0.3161    -1.176    0.6766    0.4708  0.002093
 
  D = 
            MO1  ref.MO1  ref.UO1      MD1
   MV1   0.1824   -1.265  -0.5617     1.28
 
Sample time: 0.1 seconds
Discrete-time state-space model.

Use 't' as a second argument to return a system with 3 additional inputs (input target channels corresponding to three preview steps).

Kss = ss(mpcobj, 't')
Kss =
 
  A = 
                  xMPC1       xMPC2       xMPC3       xMPC4       xMPC5
   xMPC1         0.6713     0.04207      0.1267     0.01344    -0.09876
   xMPC2        0.02215      0.7027      0.1261      0.0332    -0.08825
   xMPC3       -0.05555     -0.1095      0.7378     -0.1265      0.1711
   xMPC4       -0.05395     0.04959      0.1765      0.5649     -0.1107
   xMPC5      -0.002772    -0.01301     -0.1778    0.004795      0.7193
   xMPC6        0.09615           0     -0.1363      0.1317     0.09372
   prev.MV1     -0.6477       -0.24     -0.3161      -1.176      0.6766
 
                  xMPC6    prev.MV1
   xMPC1      -0.003895   7.095e-06
   xMPC2       -0.07105  -1.571e-05
   xMPC3        0.06713   0.0001034
   xMPC4        0.01855    0.000207
   xMPC5        0.08932  -1.435e-05
   xMPC6              1           0
   prev.MV1      0.4708    0.002093
 
  B = 
                      MO1  MV1.target(0  MV1.target(1  MV1.target(2
   xMPC1         -0.02458      0.002838    -0.0001696     -0.001357
   xMPC2         -0.02111     -0.006284     0.0003756      0.003005
   xMPC3          0.08656       0.04138     -0.002473      -0.01978
   xMPC4         -0.03556       0.08282      -0.00495       -0.0396
   xMPC5          0.01104      -0.00574     0.0003431      0.002745
   xMPC6          0.08828             0             0             0
   prev.MV1        0.1824        0.8372      -0.05003       -0.4003
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1   -0.6477     -0.24   -0.3161    -1.176    0.6766    0.4708  0.002093
 
  D = 
                 MO1  MV1.target(0  MV1.target(1  MV1.target(2
   MV1        0.1824        0.8372      -0.05003       -0.4003
 
Sample time: 0.1 seconds
Discrete-time state-space model.

You can use the second output argument to return the vector of manipulated variables target values. This vector corresponds to C.MV.Target - C.Model.Nominal.U(1).

[Kss, ut] = ss(mpcobj);
ut
ut = 3×1

   -0.6000
   -0.5000
   -0.4000

Input Arguments

collapse all

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use mpc.

Specify signals as a character vector or string with any combination that contains one or more of the following characters:

  • 'r' — Output references

  • 'v' — Measured disturbances

  • 'o' — Offset terms

  • 't' — Input targets

For example, to obtain a controller that maps [ym; r; v] to u, use:

kss = ss(MPCobj,'rv');

Example: 'r'

If this flag is 'on', then the input matrices of the returned controller have a larger size to multiply the whole reference sequence.

Example: 'on'

If this flag is 'on', then the input matrices of the returned controller have a larger size to multiply the whole disturbance sequence.

Example: 'on'

Output Arguments

collapse all

The discrete-time state space form of the unconstrained MPC controller has the following structure:

x(k + 1) = Ax(k) + Bym(k)

u(k) = Cx(k) + Dym(k)

where A, B, C, and D are the matrices forming a state space realization of the controller kss, ym is the vector of measured outputs of the plant, and u is the vector of manipulated variables. The sampling time of controller kss is MPCobj.Ts.

Note

Vector x includes the states of the observer (plant + disturbance + noise model states) and the previous manipulated variable u(k-1).

Note

Only the following fields of MPCobj are used when computing the state-space model: Model, PredictionHorizon, ControlHorizon, Ts, Weights.

Note

If MPCobj is set to use custom state estimation, then ss returns a static gain feedback matrix from the states of the augmented discrete-time plant, including previous values of the manipulated variables, to the manipulated variables.

The full discrete-time state space form of the unconstrained MPC controller has the following structure:

x(k + 1) = Ax(k) + Bym(k) + Brr(k) + Bvv(k) + Bututarget(k) + Boff

u(k) = Cx(k) + Dym(k) + Drr(k) + Dvv(k) + Dututarget(k) + Doff

Here:

  • A, B, C, and D are the matrices forming a state space realization of the controller from measured plant output to manipulated variables

  • r is the vector of setpoints for both measured and unmeasured plant outputs

  • v is the vector of measured disturbances.

  • utarget is the vector of preferred values for manipulated variables.

In the general case of nonzero offsets, ym, r, v, and utarget must be interpreted as the difference between the vector and the corresponding offset. Offsets can be nonzero is MPCobj.Model.Nominal.Y or MPCobj.Model.Nominal.U are nonzero.

Vectors Boff and Doff are constant terms. They are nonzero if and only if MPCobj.Model.Nominal.DX is nonzero (continuous-time prediction models), or MPCobj.Model.Nominal.Dx-MPCobj.Model.Nominal.X is nonzero (discrete-time prediction models). In other words, when Nominal.X represents an equilibrium state, Boff, Doff are zero.

If the flag refPreview = 'on', then matrices Br and Dr multiply the whole reference sequence:

x(k + 1) = Ax(k) + Bym(k) + Br[r(k);r(k + 1);...;r(k + p – 1)] +...

u(k) = Cx(k) + Dym(k) + Dr[r(k);r(k + 1);...;r(k + p– 1)] +...

Similarly, if the flag mdPreview='on', then matrices Bv and Dv multiply the whole measured disturbance sequence:

x(k + 1) = Ax(k) +...+ Bv[v(k);v(k + 1);...;v(k + p)] +...

u(k) = Cx(k) +...+ Dv[v(k);v(k + 1);...;v(k + p)] +...

ut is returned as a vector of doubles, [utarget(k); utarget(k+1); ... utarget(k+h)].

Here:

  • h — Maximum length of previewed inputs; that is, h = max(length(MPCobj.ManipulatedVariables(:).Target))

  • utarget — Difference between the input target and corresponding input offsets; that is, MPCobj.ManipulatedVariables(:).Targets - MPCobj.Model.Nominal.U

Version History

Introduced before R2006a