Steady-state operating point from specifications (trimming) or simulation

returns
the operating point of the model that meets the specifications in `op`

= findop(`sys`

,`opspec`

)`opspec`

.
Typically, you trim the model at a steady-state operating point.
The Simulink^{®} model must be open. If `opspec`

is
an array of operating points specifications, `findop`

returns
an array of corresponding operating points.

Open the Simulink model.

```
sys = 'watertank';
open_system(sys)
```

Trim the model to find a steady-state operating point where the water tank level is `10`

.

Create default operating point specification object.

opspec = operspec(sys);

Configure specifications for the first model state. The first state must be at steady state with a lower bound of `0`

. Provide an initial guess of `2`

for the state value.

opspec.States(1).SteadyState = 1; opspec.States(1).x = 2; opspec.States(1).Min = 0;

Configure the second model state as a known state with a value of `10`

.

opspec.States(2).Known = 1; opspec.States(2).x = 10;

Find the operating point that meets these specifications.

op = findop(sys,opspec);

Operating point search report: --------------------------------- Operating point search report for the Model watertank. (Time-Varying Components Evaluated at time t=0) Operating point specifications were successfully met. States: ---------- (1.) watertank/PID Controller/Integrator x: 1.26 dx: 0 (0) (2.) watertank/Water-Tank System/H x: 10 dx: 0 (0) Inputs: None ---------- Outputs: None ----------

Open the Simulink model.

```
sys = 'watertank';
open_system(sys)
```

Vary parametsrs `A`

and `b`

within 10% of their nominal values, and create a 3-by-4 parameter grid.

```
[A_grid,b_grid] = ndgrid(linspace(0.9*A,1.1*A,3),...
linspace(0.9*b,1.1*b,4));
```

Create a parameter structure array, specifying the name and grid points for each parameter.

params(1).Name = 'A'; params(1).Value = A_grid; params(2).Name = 'b'; params(2).Value = b_grid;

Create a default operating point specification for the model.

opspec = operspec(sys);

Trim the model using the specified operating point specification and parameter grid.

opt = findopOptions('DisplayReport','off'); op = findop(sys,opspec,params,opt);

`op`

is a 3-by-4 array of operating point objects that correspond to the specified parameter grid points.

Open the Simulink model.

```
sys = 'watertank';
open_system(sys)
```

Create a default operating point specification object.

opspec = operspec(sys);

Create an option set that sets the optimizer type to gradient descent and suppresses the search report display.

opt = findopOptions('OptimizerType','graddescent','DisplayReport','off');

Trim the model using the specified option set.

op = findop(sys,opspec,opt);

Open the Simulink model.

```
sys = 'watertank';
open_system(sys)
```

Create default operating point specification object.

opspec = operspec(sys);

Configure specifications for the first model state.

opspec.States(1).SteadyState = 1; opspec.States(1).x = 2; opspec.States(1).Min = 0;

Configure specifications for the second model state.

opspec.States(2).Known = 1; opspec.States(2).x = 10;

Find the operating point that meets these specifications, and return the operating point search report. Create an option set to suppress the search report display.

```
opt = findopOptions('DisplayReport',false);
[op,opreport] = findop(sys,opspec,opt);
```

`opreport`

describes how closely the optimization algorithm met the specifications at the end of the operating point search.

opreport

Operating point search report for the Model watertank. (Time-Varying Components Evaluated at time t=0) Operating point specifications were successfully met. States: ---------- (1.) watertank/PID Controller/Integrator x: 1.26 dx: 0 (0) (2.) watertank/Water-Tank System/H x: 10 dx: 0 (0) Inputs: None ---------- Outputs: None ----------

`dx`

is the time derivative for each state. Since all `dx`

values are zero, the operating point is at steady state.

Open the Simulink model.

```
sys = 'magball';
open_system(sys)
```

Simulate the model, and extract operating points at `10`

and `20`

time units.

op = findop(sys,[10,20]);

`op`

is a column vector of operating points, with one element for each snapshot time.

Display the first operating point.

op(1)

Operating point for the Model magball. (Time-Varying Components Evaluated at time t=10) States: ---------- (1.) magball/Controller/PID Controller/Filter x: 5.47e-07 (2.) magball/Controller/PID Controller/Integrator x: 14 (3.) magball/Magnetic Ball Plant/Current x: 7 (4.) magball/Magnetic Ball Plant/dhdt x: 8.44e-08 (5.) magball/Magnetic Ball Plant/height x: 0.05 Inputs: None ----------

Open Simulink model.

```
sys = 'watertank';
open_system(sys)
```

Specify parameter values. The parameter grids are 5-by-4 arrays.

[A_grid,b_grid] = ndgrid(linspace(0.9*A,1.1*A,5),... linspace(0.9*b,1.1*b,4)); params(1).Name = 'A'; params(1).Value = A_grid; params(2).Name = 'b'; params(2).Value = b_grid;

Simulate the model and extract operating points at `0`

, `5`

, and `10`

time units.

op = findop(sys,[0 5 10],params);

`findop`

simulates the model for each parameter value combination, and extracts operating points at the specified simulation times.

`op`

is a 3-by-5-by-4 array of operating point objects.

size(op)

ans = 3 5 4

`sys`

— Simulink model namecharacter vector

Simulink model name, specified as a character vector.

`opspec`

— Operating point specifications`operspec`

object | array of `operspec`

objectsOperating point specifications for trimming the model, specified
as an `operspec`

object or
an array of `operspec`

objects.

If `opspec`

is an array, `findop`

returns
an array of corresponding operating points using a single model compilation.

`param`

— Parameter samplesstructure | structure array

Parameter samples for trimming, specified as one of the following:

Structure — Vary the value of a single parameter by specifying

`param`

as a structure with the following fields:`Name`

— Parameter name, specified as a character vector. You can specify any model parameter that is a variable in the model workspace, the MATLAB^{®}workspace, or a data dictionary. If the variable used by the model is not a scalar variable, specify the parameter name as an expression that resolves to a numeric scalar value. For example, to use the first element of vector`V`

as a parameter, use:`param.Name = 'V(1)';`

`Value`

— Parameter sample values, specified as a double array.

For example, vary the value of parameter

`A`

in the 10% range:`param.Name = 'A'; param.Value = linspace(0.9*A,1.1*A,3);`

Structure array — Vary the value of multiple parameters. For example, vary the values of parameters

`A`

and`b`

in the 10% range:[A_grid,b_grid] = ndgrid(linspace(0.9*A,1.1*A,3),... linspace(0.9*b,1.1*b,3)); params(1).Name = 'A'; params(1).Value = A_grid; params(2).Name = 'b'; params(2).Value = b_grid;

When you specify parameter value variations, `findop`

batch
trims the model for each parameter value combination, and returns
an array of corresponding operating points. If `param`

specifies
tunable parameters only, then the software batch trims the model using
a single compilation.

If you specify `opspec`

as a single `operspec`

object
and the parameter values in `param`

produce states
that conflict with known states in `opspec`

, `findop`

trims
the model using the specifications in `opspec`

.
To trim the model at state values derived from the parameter values,
specify `opspec`

as an array of corresponding `operspec`

objects.
For an example, see Batch Trim Simulink Model for Parameter Variation.

`options`

— Trimming options`findopOptions`

option setTrimming options, specified as a `findopOptions`

option
set.

`tsnapshot`

— Simulation snapshot timesscalar | vector

Simulation snapshot times at which to extract the operating
point of the model, specified as a scalar for a single snapshot or
a vector for multiple snapshots. `findop`

simulates
the model and computes an operating point for the state of the model
at each snapshot time.

`op`

— Operating pointoperating point object | array of operating point objects

Operating point, returned as an operating point object or an
array of operating point objects. The dimensions of `op`

depend
on the specified parameter variations and either the operating point
specifications or the simulation snapshot time.

Parameter Variation | Find operating point for... | Resulting `op` Dimensions |
---|---|---|

No parameter variation | Single operating point specification, specified by `opspec` | single operating point object |

Single snapshot time, specified by `tsnapshot` | ||

N-by-_{1}`...` -by-N array
of operating point specifications, specified by _{m}`opspec` | N-by-_{1}`...` -by-N_{m} | |

N snapshots, specified
by _{s}`tsnapshot` | Column vector of length N_{s} | |

N-by-_{1}`...` -by-N parameter
grid, specified by _{m}`param` | Single operating point specification, specified by `opspec` | N-by-_{1}`...` -by-N_{m} |

Single snapshot time, specified by `tsnapshot` | ||

N-by-_{1}`...` -by-N array
of operating point specifications, specified by _{m}`opspec` | ||

N snapshots, specified
by _{s}`tsnapshot` | N-by-_{s}N-by-_{1}`...` -by-N._{m} |

For example, suppose:

`opspec`

is a single operating point specification object and`param`

specifies a 3-by-4-by-2 parameter grid. In this case,`op`

is a 3-by-4-by-2 array of operating points.`tsnapshot`

is a scalar and`param`

specifies a 5-by-6 parameter grid. In this case,`op`

is a 1-by-5-by-6 array of operating points.`tsnapshot`

is a row vector with three elements and`param`

specifies a 5-by-6 parameter grid. In this case,`op`

is a 3-by-5-by-6 array of operating points.

Each operating point object has the following properties:

Property | Description | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

`Model` | Simulink model name, returned as a character vector. | |||||||||||||||||||

`States` | State operating point, returned as a vector of state
objects. Each entry in For a list of supported states for operating point objects, see Simulink Model States Included in Operating Point Object.
Each state object has the following fields:
| |||||||||||||||||||

`Inputs` | Input level at the operating point, returned as a vector
of input objects. Each entry in Each entry input object has the following fields:
| |||||||||||||||||||

`Time` | Times at which any time-varying functions in the model are evaluated, returned as a vector. | |||||||||||||||||||

`Version` | Object version number |

You can edit the properties of `op`

using
dot notation or the `set`

function.

`opreport`

— Operating point search reportoperating point search report object | array of operating point search report objects

Operating point search report, returned as an operating point
search report object. If `op`

is an array of operating
point objects, then `opreport`

is an array of corresponding
search reports.

This report displays automatically, even when you suppress the
output using a semicolon. To hide the report, set the `DisplayReport`

field
in `options`

to `'off'`

.

Each operating point search report has the following properties:

Property | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

`Model` |
| ||||||||||||||||||

`Inputs` |
| ||||||||||||||||||

`Outputs` |
| ||||||||||||||||||

`States` |
| ||||||||||||||||||

`Time` | `Time` property value of `op` | ||||||||||||||||||

`TerminationString` | Optimization termination condition, returned as a character vector. | ||||||||||||||||||

`OptimizationOutput` | Optimization algorithm search results, returned as a structure
with the following fields:
For more information about the optimization algorithm, see the Optimization Toolbox™ documentation. |

As an alternative to the `findop`

command,
you can find operating points using the Linear Analysis Tool. For
more information, see the following examples:

A *steady-state operating point* of a model,
also called an equilibrium or *trim* condition,
includes state variables that do not change with time.

A model can have several steady-state operating points. For
example, a hanging damped pendulum has two steady-state operating
points at which the pendulum position does not change with time. A *stable
steady-state operating point* occurs when a pendulum hangs
straight down. When the pendulum position deviates slightly, the pendulum
always returns to equilibrium. In other words, small changes in the
operating point do not cause the system to leave the region of good
approximation around the equilibrium value.

An *unstable steady-state operating point* occurs
when a pendulum points upward. As long as the pendulum points *exactly* upward,
it remains in equilibrium. However, when the pendulum deviates slightly
from this position, it swings downward and the operating point leaves
the region around the equilibrium value.

When using optimization search to compute operating points for nonlinear systems, your initial guesses for the states and input levels must be near the desired operating point to ensure convergence.

When linearizing a model with multiple steady-state operating points, it is important to have the right operating point. For example, linearizing a pendulum model around the stable steady-state operating point produces a stable linear model, whereas linearizing around the unstable steady-state operating point produces an unstable linear model.

You can initialize an operating point search at a simulation snapshot or a previously computed operating point using

`initopspec`

.Linearize the model at the operating point

`op`

using`linearize`

.

By default, `findop`

uses the optimizer `graddescent_elim`

.
To use a different optimizer, change the value of `OptimizerType`

in `options`

using `findopOptions`

.

`findop`

automatically sets these Simulink model
properties for optimization:

`BufferReuse = 'off'`

`RTWInlineParameters = 'on'`

`BlockReductionOpt = 'off'`

`SaveFormat = 'StructureWithTime'`

After the optimization completes, Simulink restores the original model properties.

`addoutputspec`

| `findopOptions`

| `initopspec`

| `linearize`

| `operspec`

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Was this topic helpful?

You can also select a location from the following list:

- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)