# trim

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

## Syntax

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

## Description

The `trim` function finds 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, xoff, uoff, and yoff are the nominal values of the extended state x, input u, and output y respectively.

`x` is returned as an `mpcstate` object. Specify `y` and `u` as doubles. `y` specifies the measured and unmeasured output values. `u` specifies the manipulated variable, measured disturbance, and unmeasured disturbance values. The values for unmeasured disturbances must be `0`.

`trim` assumes the disturbance model and measurement noise model to be zero when computing the steady-state value. The software uses the extended state vector to perform the calculation.