Main Content

Operating point specifications

Open Simulink model.

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

Create the default operating point specification object for the model.

opspec = operspec(sys)

opspec = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- <strong>x</strong> <strong>Known</strong> <strong>SteadyState</strong> <strong>Min</strong> <strong>Max</strong> <strong>dxMin</strong> <strong>dxMax</strong> <strong>_</strong> <strong>_____</strong> <strong>___________</strong> <strong>____</strong> <strong>___</strong> <strong>_____</strong> <strong>_____</strong> (1.) watertank/PID Controller/Integrator/Continuous/Integrator 0 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------

`opspec`

contains specifications for the two states in the model. Since the model has no root level inports or outports, `opspec`

does not contain input or output specifications. To add output specifications, use `addoutputspec`

.

Modify the operating point specifications for each state using dot notation. For example, configure the first state to:

Be at steady state.

Have a lower bound of

`0`

.Have an initial value of

`2`

for trimming.

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

You can create new `operspec`

variables in three ways:

Using the

`operspec`

commandUsing assignment with the equals (

`=`

) operatorUsing the

`copy`

command

Using the `=`

operator results in linked variables that both point to the same underlying data. Using the `copy`

command results in an independent `operspec`

object. In this example, create `operspec`

objects both ways, and examine their behavior.

```
mdl = 'watertank';
open_system(mdl)
opspec1 = operspec(mdl)
```

opspec1 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax _ _____ ___________ ____ ___ _____ _____ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 0 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------

Create a new operating point specification object using assignment with the `=`

operator.

opspec2 = opspec1;

`opspec2`

is an `operspec`

object that points to the same underlying data as `opspec1`

. Because of this link, you cannot independently change properties of the two `operspec`

objects. To see this, change a property of `opspec2`

. For instance, change the initial value for the first state from 0 to 2. The change shows in the `States`

section of the display.

opspec2.States(1).x = 2

opspec2 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax _ _____ ___________ ____ ___ _____ _____ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------

Examine the display of `opspec1`

to see that the corresponding property value of `opspec1`

also changes from 0 to 2.

opspec1

opspec1 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax _ _____ ___________ ____ ___ _____ _____ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 2 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------

To create an independent copy of an operating point specification, use the `copy`

command.

opspec3 = copy(opspec1);

Now, when you change a property of `opspec3`

, `opspec1`

does not change. For instance, change the initial value for the first state from 2 to 4.

opspec3.States(1).x = 4

opspec3 = Operating point specification for the Model watertank. (Time-Varying Components Evaluated at time t=0) States: ---------- x Known SteadyState Min Max dxMin dxMax _ _____ ___________ ____ ___ _____ _____ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 4 false true -Inf Inf -Inf Inf (2.) watertank/Water-Tank System/H 1 false true 0 Inf -Inf Inf Inputs: None ---------- Outputs: None ----------

In `opspec1`

, the corresponding value remains 2.

opspec1.States(1).x

ans = 2

This copy behavior occurs because `operspec`

is a *handle object*. For more information about handle objects, see Handle Object Behavior.

Open Simulink model.

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

Create a 2-by-3 array of operating point specification objects. You can batch trim model at multiple operating points using such arrays.

opspec = operspec(sys,[2,3]);

Each element of `opspec`

contains a default operating point specification object for the model.

Modify the operating point specification objects using dot notation. For example, configure the second state of the specification object in row `1`

, column `3`

.

opspec(1,3).States(2).SteadyState = 1; opspec(1,3).States(1).x = 2;

You can also create multidimensional arrays of operating point specification objects. For example, create a 3-by-4-by-5 array.

opspec = operspec(sys,[3,4,5]);

`mdl`

— Simulink modelcharacter vector | string

Simulink model name, specified as a character vector or string.

`dim`

— Array dimensionsinteger | row vector of integers

Array dimensions, specified as one of the following:

Integer — Create a column vector of

`dim`

operating point specification objects.Row vector of integers — Create an array of operating point specification objects with the dimensions specified by

`dim`

.For example, to create a 4-by-5 array of operating point specification objects, use:

opspec = operspec(mdl,[4,5]);

To create a multidimensional array of operating point specification objects, specify additional dimensions. For example, to create a 2-by-3-by-4 array, use:

opspec = operspec(mdl,[2,3,4]);

`opspec`

— Operating point specifications`OperatingSpec`

object | array of `OperatingSpec`

objectsOperating point specifications, returned as an `OperatingSpec`

object or an
array of such objects.

You can modify the operating point specifications using dot notation. For example, if
`opspec`

is a single `OperatingSpec`

object, `opspec.States(1).x`

accesses the state values of
the first model state. If `opspec`

is an array of
`OperatingSpec`

objects
`opspec(2,3).Inputs(1).u`

accesses the input level of
the first inport block for the specification in row `2`

,
column `3`

.

Each `OperatingSpec`

object has the following properties.

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

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

`States` | State operating point specifications, returned as a vector
of state specification objects. Each entry in For a
list of supported states for operating point objects, see Simulink Model States Included in Operating Point Object.
Edit the properties of this object using dot notation or the
If the block has multiple named continuous states, Each state specification object has the following fields:
| ||||||||||||||||||||||||||||||

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

`Outputs` | Output level specifications at the operating point, returned
as a vector of output specification objects. Each entry in You can specify
additional trim output constraints using Each output specification object has the following fields:
| ||||||||||||||||||||||||||||||

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

`CustomObjFcn` | Function providing an additional custom objective function
for trimming, specified as a handle to the custom function, or a character
vector or string that contains the function name. The custom function
must be on the MATLAB You can specify a custom objective function as an algebraic combination of model states, inputs, and outputs. For more information, see Compute Operating Points Using Custom Constraints and Objective Functions. | ||||||||||||||||||||||||||||||

`CustomConstrFcn` | Function providing additional custom constraints for trimming, specified as a handle to the custom function, or a character vector or string that contains the function name. The custom function must be on the MATLAB path or in the current working folder. You can specify custom equality and inequality constraints as algebraic combinations of model states, inputs, and outputs. For more information, see Compute Operating Points Using Custom Constraints and Objective Functions. | ||||||||||||||||||||||||||||||

`CustomMappingFcn` | Function that maps model states, inputs, and outputs
to the vectors accepted by For complex models, you can pass subsets of the model inputs, outputs, and states to the custom constraint and objective functions using a custom mapping function. If you specify a custom mapping, you must use the mapping for both the custom constraint function and the custom objective function. For more information, see Compute Operating Points Using Custom Constraints and Objective Functions. |

To display the operating point specification object properties, use

`get`

.You can create new

`operspec`

variables of in 3 ways:Construct a new object with the

`operspec`

command.Create a new variable by assignment with the equals (=) operator.

Copy an

`operspec`

object using the`copy`

command.

Using

`operspec`

or`copy`

creates a new, independent object. When you use assignment, there is a link between the old and new variable. For an example, see Copy an Operating-Point Specification.

`PortWidth`

property of operating point specification inputs and outputs will be removed*Not recommended starting in R2021b*

The input and output `PortWidth`

properties of operating point
specifications will be removed in a future release. Use the new
`Nu`

and `Ny`

properties instead.

To update your code, change instances of `PortWidth`

to either
`Nu`

or `Ny`

as shown in the following
table.

Not Recommended | Recommended |
---|---|

op = operspec('scdplane'); numOut = op.Outputs(1).PortWidth; numIn = op.Inputs(1).PortWidth; |
op = operspec('scdplane'); numOut = op.Outputs(1).Ny; numIn = op.Inputs(1).Nu; |

`findop`

| `addoutputspec`

| `update`

| `copy`

You have a modified version of this example. Do you want to open this example with your edits?

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.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- 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)