# trim

Find trim point of dynamic system

## Syntax

`[x,u,y,dx] = trim('`

* sys*')

[x,u,y,dx] = trim('

*',x0,u0,y0)*

`sys`

[x,u,y,dx] = trim('

*',x0,u0,y0,ix,iu,iy)*

`sys`

[x,u,y,dx] = trim('

*',x0,u0,y0,ix,iu,iy,dx0,idx)*

`sys`

[x,u,y,dx,options] = trim('

*',x0,u0,y0,ix,iu,iy,dx0,idx,options)*

`sys`

[x,u,y,dx,options] = trim('

*',x0,u0,y0,ix,iu,iy,dx0,idx,options,t)*

`sys`

## Description

**Note**

`trim`

provides only basic trimming functionality. For full
trimming functionality, use Simulink^{®}
Control Design™ software. For more information, see Compute Steady-State Operating Points (Simulink Control Design).

A trim point, also known as an equilibrium point, is a point in the parameter space of
a dynamic system at which the system is in a steady state. For example, a trim point of
an aircraft is a setting of its controls that causes the aircraft to fly straight and
level. Mathematically, a trim point is a point where the system's state derivatives
equal zero. `trim`

starts from an initial point and searches, using a
sequential quadratic programming algorithm, until it finds the nearest trim point. You
must supply the initial point implicitly or explicitly. If `trim`

cannot find a trim point, it returns the point encountered in its search where the state
derivatives are closest to zero in a min-max sense; that is, it returns the point that
minimizes the maximum deviation from zero of the derivatives. `trim`

can find trim points that meet specific input, output, or state conditions, and it can
find points where a system is changing in a specified manner, that is, points where the
system's state derivatives equal specific nonzero values.

`[x,u,y,dx] = trim('`

finds the
equilibrium point of the model '* sys*')

*', nearest to the system's initial state,*

`sys`

`x0`

. Specifically, `trim`

finds the
equilibrium point that minimizes the maximum absolute value of
`[x-x0,u,y]`

. If `trim`

cannot find an equilibrium
point near the system's initial state, it returns the point at which the system is
nearest to equilibrium. Specifically, it returns the point that minimizes
`abs(dx)`

where `dx`

represents the derivative of
the system. You can obtain `x0`

using this command.[sizes,x0,xstr] = sys([],[],[],0)

`[x,u,y,dx] = trim('`

finds the trim point nearest to * sys*',x0,u0,y0)

`x0`

, `u0`

,
`y0`

, that is, the point that minimizes the maximum value of abs([x-x0; u-u0; y-y0])

**Caution**

When you use the `trim`

function to find a trim point near a
specified initial operating point,

The `trim`

function returns only a local value when you use the
function to find a trim point near a specified initial operating point. Other, more
suitable trim points might exist. To find the most suitable trim point for a
particular application, as a best practice, try a number of initial guesses for the
initial state, input, and output values.

`[x,u,y,dx] = trim('`

finds the trim point closest to * sys*',x0,u0,y0,ix,iu,iy)

`x0`

, `u0`

,
`y0`

that satisfies a specified set of state, input, and/or output
conditions. The integer vectors `ix`

, `iu`

, and
`iy`

select the values in `x0`

,
`u0`

, and `y0`

that must be satisfied. If
`trim`

cannot find an equilibrium point that satisfies the
specified set of conditions exactly, it returns the nearest point that satisfies the
conditions, namely,abs([x(ix)-x0(ix); u(iu)-u0(iu); y(iy)-y0(iy)])

`[x,u,y,dx] = trim('`

finds specific nonequilibrium points, that is, points at which the system's state
derivatives have some specified nonzero value. Here, * sys*',x0,u0,y0,ix,iu,iy,dx0,idx)

`dx0`

specifies
the state derivative values at the search's starting point and `idx`

selects the values in `dx0`

that the search must satisfy
exactly.`[x,u,y,dx,options] = trim('`

specifies an array of optimization parameters that * sys*',x0,u0,y0,ix,iu,iy,dx0,idx,options)

`trim`

passes to the
optimization function that it uses to find trim points. The optimization function, in
turn, uses this array to control the optimization process and to return information
about the process. `trim`

returns the `options`

array
at the end of the search process. By exposing the underlying optimization process in
this way, `trim`

allows you to monitor and fine-tune the search for
trim points.The following table describes how each element affects the search for a trim point. Array elements 1, 2, 3, 4, and 10 are particularly useful for finding trim points.

No. | Default | Description |
---|---|---|

1 | 0 | Specifies display options. 0 specifies no display; 1 specifies tabular output; -1 suppresses warning messages. |

2 | 10^{–4} | Precision the computed trim point must attain to terminate the search. |

3 | 10^{–4} | Precision the trim search goal function must attain to terminate the search. |

4 | 10^{–6} | Precision the state derivatives must attain to terminate the search. |

5 | N/A | Not used. |

6 | N/A | Not used. |

7 | N/A | Used internally. |

8 | N/A | Returns the value of the trim search goal function (λ in goal attainment). |

9 | N/A | Not used. |

10 | N/A | Returns the number of iterations used to find a trim point. |

11 | N/A | Returns the number of function gradient evaluations. |

12 | 0 | Not used. |

13 | 0 | Number of equality constraints. |

14 | 100*(Number of variables) | Maximum number of function evaluations to use to find a trim point. |

15 | N/A | Not used. |

16 | 10^{–8} | Used internally. |

17 | 0.1 | Used internally. |

18 | N/A | Returns the step length. |

`[x,u,y,dx,options] = trim('`

sets the time to * sys*',x0,u0,y0,ix,iu,iy,dx0,idx,options,t)

`t`

if the system is dependent on time.**Note**

If you fix any of the state, input, or output values, the
`trim`

function uses the unspecified free variables to
derive the solution that satisfies the specified constraints.

## Examples

## Algorithms

The `trim`

function uses a sequential quadratic programming
algorithm to find trim points. For a description of this algorithm, see Sequential Quadratic Programming (SQP) (Optimization Toolbox).

## Version History

**Introduced before R2006a**

## See Also

`findop`

(Simulink Control Design)

### Topics

- Compute Steady-State Operating Points (Simulink Control Design)