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.

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.

example

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);
-->"PredictionHorizon" is empty. Assuming default 10.
-->"ControlHorizon" is empty. Assuming default 2.
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
-->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
-->"Weights.OutputVariables" 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 #1.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

Kss =
 
  A = 
                  xMPC1       xMPC2       xMPC3       xMPC4       xMPC5       xMPC6    prev.MV1
   xMPC1           0.76      0.2216   -0.006469      0.3508     0.02977    -0.04783   3.019e-05
   xMPC2         -0.231       1.135     -0.4594      0.5914     0.01656     -0.1007   7.773e-08
   xMPC3       -0.03007      0.1185      0.5467      0.1386     0.01752       -0.11   0.0001122
   xMPC4        -0.1927     -0.2434     -0.1331      0.2121    -0.02496     -0.1596   0.0001298
   xMPC5        -0.1399     -0.2179     0.09667     -0.3748      0.5926      0.1385  -2.941e-05
   xMPC6       -0.09826           0      0.1393     -0.1346    -0.09578           1           0
   prev.MV1      -2.511     0.02726      -2.984        -1.2    -0.08729      -2.102    0.001735
 
  B = 
                  MO1
   xMPC1      0.05903
   xMPC2       0.1294
   xMPC3      0.03619
   xMPC4      -0.0589
   xMPC5     -0.08955
   xMPC6     -0.09022
   prev.MV1   0.09002
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1    -2.511   0.02726    -2.984      -1.2  -0.08729    -2.102  0.001735
 
  D = 
            MO1
   MV1  0.09002
 
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 #1.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

K =
 
  D = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1    -2.609   0.02726    -2.845    -1.334   -0.1829    -2.102  0.001735
 
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 #1.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

Kss =
 
  A = 
                  xMPC1       xMPC2       xMPC3       xMPC4       xMPC5       xMPC6    prev.MV1
   xMPC1           0.76      0.2216   -0.006469      0.3508     0.02977    -0.04783   3.019e-05
   xMPC2         -0.231       1.135     -0.4594      0.5914     0.01656     -0.1007   7.773e-08
   xMPC3       -0.03007      0.1185      0.5467      0.1386     0.01752       -0.11   0.0001122
   xMPC4        -0.1927     -0.2434     -0.1331      0.2121    -0.02496     -0.1596   0.0001298
   xMPC5        -0.1399     -0.2179     0.09667     -0.3748      0.5926      0.1385  -2.941e-05
   xMPC6       -0.09826           0      0.1393     -0.1346    -0.09578           1           0
   prev.MV1      -2.511     0.02726      -2.984        -1.2    -0.08729      -2.102    0.001735
 
  B = 
                    MO1     ref.MO1     ref.UO1         MD1
   xMPC1        0.05903   -0.003162    -0.03311    -0.06524
   xMPC2         0.1294  -8.142e-06  -8.526e-05  -0.0008242
   xMPC3        0.03619    -0.01175      -0.123     0.08255
   xMPC4        -0.0589    -0.01359     -0.1423     0.03386
   xMPC5       -0.08955    0.003081     0.03226   -0.005793
   xMPC6       -0.09022           0           0           0
   prev.MV1     0.09002     -0.1817      -1.903       1.503
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1    -2.511   0.02726    -2.984      -1.2  -0.08729    -2.102  0.001735
 
  D = 
            MO1  ref.MO1  ref.UO1      MD1
   MV1  0.09002  -0.1817   -1.903    1.503
 
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       xMPC6    prev.MV1
   xMPC1           0.76      0.2216   -0.006469      0.3508     0.02977    -0.04783   3.019e-05
   xMPC2         -0.231       1.135     -0.4594      0.5914     0.01656     -0.1007   7.773e-08
   xMPC3       -0.03007      0.1185      0.5467      0.1386     0.01752       -0.11   0.0001122
   xMPC4        -0.1927     -0.2434     -0.1331      0.2121    -0.02496     -0.1596   0.0001298
   xMPC5        -0.1399     -0.2179     0.09667     -0.3748      0.5926      0.1385  -2.941e-05
   xMPC6       -0.09826           0      0.1393     -0.1346    -0.09578           1           0
   prev.MV1      -2.511     0.02726      -2.984        -1.2    -0.08729      -2.102    0.001735
 
  B = 
                      MO1  MV1.target(0  MV1.target(1  MV1.target(2
   xMPC1          0.05903       0.01207     -0.001223     -0.009782
   xMPC2           0.1294     3.109e-05    -3.149e-06    -2.519e-05
   xMPC3          0.03619       0.04487     -0.004544      -0.03635
   xMPC4          -0.0589       0.05191     -0.005257      -0.04206
   xMPC5         -0.08955      -0.01176      0.001191       0.00953
   xMPC6         -0.09022             0             0             0
   prev.MV1       0.09002        0.6938      -0.07026       -0.5621
 
  C = 
           xMPC1     xMPC2     xMPC3     xMPC4     xMPC5     xMPC6  prev.MV1
   MV1    -2.511   0.02726    -2.984      -1.2  -0.08729    -2.102  0.001735
 
  D = 
                 MO1  MV1.target(0  MV1.target(1  MV1.target(2
   MV1       0.09002        0.6938      -0.07026       -0.5621
 
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