# trim

Compute steady-state value of MPC controller plant model state for given inputs and outputs

## Syntax

``x = trim(MPCobj,y,u)``

## Description

Use the Model Predictive Control Toolbox™ `trim` function to calculate steady state values of LTI discrete-time plants controlled by an MPC controller (see `mpc` for background).

To find operating points of dynamic systems instead, see `trim` (Simulink) and Compute Steady-State Operating Points (Simulink Control Design).

example

````x = trim(MPCobj,y,u)` returns a steady-state value for the plant state or the best approximation in a least squares sense such that: $\begin{array}{l}x-{x}_{off}=A\left(x-{x}_{off}\right)+B\left(u-{u}_{off}\right)\\ y-{y}_{off}=C\left(x-{x}_{off}\right)+D\left(u-{u}_{off}\right)\end{array}$Here, A,B, C, and D are the state space realization matrices of the discrete-time plant model used within `MPCobj`, xoff, uoff, and yoff are the nominal values of the extended state x, input u, and output y respectively.```

## Examples

collapse all

Create a plant, a corresponding MPC object, and calculate the steady state value of the plant model state.

```mpcverbosity off; % turn off mpc messaging plant=c2d(ss(zpk([],[-1 -10],20)),1); % create plant (note the steady state gain) mpcobj=mpc(plant,1); % create mpc object x=trim(mpcobj,2,1) % caclulate trim point MPCSTATE object with fields Plant: [0.4000 0.4000] Disturbance: 0 Noise: [1×0 double] LastMove: 1 Covariance: [3×3 double] % check whether the calculated value is actually an equilibrium point mpcobj.Model.Plant.A*x.Plant+mpcobj.Model.Plant.B*1-x.Plant ans = 1.0e-15 * 0.1110 0.0555 mpcobj.Model.Plant.C*x.Plant+mpcobj.Model.Plant.D*1-2 ans = -2.2204e-16```

The resulting state value is an equilibrium point because for the given output and input values, the state at the next time step is equal to the current state (except some numerical errors).

## Input Arguments

collapse all

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

This is the plant output (including both measured and unmeasured signals) for which you want to find a stationary value of the extended plant state. If the plant has a finite steady state gain matrix `G0` and `y` is equal to `G0*u` then the plant has a stationary state with output `y` and input `u`.

Example: `[1 1]'`

This is the plant input (including manipulated variables, measured disturbances, and unmeasured disturbances) for which you want to find a stationary value of the extended plant state. If unmeasured input disturbance variables exist, their value must be `0`.

Example: `[0 1]'`

## Output Arguments

collapse all

This is the best approximation, in a least squares sense, of the steady-state value for the plant state corresponding to the given input and output values.

## Version History

Introduced before R2006a