| Contents | Index |
You can compute a steady-state operating point (or equilibrium operating point) using numerical optimization methods to meet your specifications. The resulting operating point consists of the equilibrium state values and model input levels.
Optimization-based operating point computation requires you to specify initial guesses and constraints on the key operating point states, input levels, and model output signals.
You can usually improve your optimization results using simulation to initialize the optimization. For example, you can extract the initial values of the operating point at a simulation time when the model reaches the neighborhood of steady state.
Optimization-based operating point search lets you specify and constrain the following variables at equilibrium:
Initial state values
States at equilibrium
Maximum or minimum bounds on state values, input levels, and output levels
Known (fixed) state values, input levels, or output levels
Your operating point search might not converge to a steady-state operating point when you overconstrain the optimization. You can overconstrain the optimization by specifying incompatible constraints or initial guesses that are far away from the desired solution.
You can also control the accuracy of your operating point search by configuring the optimization algorithm settings.
When configuring a steady-state operating point search, you do not always need to specify all states to be at equilibrium. A pendulum is an example of a system where it is possible to find an operating point with all states at steady state. However, for other types of systems, there may not be an operating point where all states are at equilibrium, and the application does not require that all operating point states be at equilibrium.
For example, suppose you build an automobile model for a cruise control application with these states:
Vehicle position and velocity
Fuel and air flow rates into the engine
If your goal is to study the automobile behavior at constant cruising velocity, you need an operating point with the velocity, air flow rate, and fuel flow rate at steady state. However, the position of the vehicle is not at steady state because the vehicle is moving at constant velocity. The lack of steady state of the position variable is fine for the cruise control application because the position does not have significant impact on the cruise control behavior. In this case, you do not need to overconstrain the optimization search for an operating point by require that all states should be at equilibrium.
Similar situations also appear in aerospace systems when analyzing the dynamics of an aircraft under different maneuvers.
This example shows how to compute a steady-state operating point, or equilibrium operating point, by specifying known (fixed) equilibrium states and minimum state values.
Open Simulink model.
sys = 'magball'; open_system(sys)

In the Simulink model window, select Tools > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.

Select Trim Model > Specifications in the Linear Analysis tab.
By default, all model states are specified to be at equilibrium (as shown in the Steady State column). The Inputs and Outputs tabs are empty because this model does not have root-level input and output ports, respectively.

In the States tab, select Known for the height state.
The height of the ball should match the reference signal height. This height value should remain fixed during the optimization.

Enter 0 for the minimum bound of the Current state.

Click Trim to compute the operating point.

This action uses numerical optimization to find the operating point that meets your specifications.
The Trim progress viewer shows that the optimization algorithm terminated successfully. The (Maximum Error) Block area shows the progress of reducing the error of a specific state or output during the optimization.

A new variable, op_trim1, appears in the Linear Analysis Workspace.

Double click op_trim1 in Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.
The Actual dx values are near zero, the desired result, which indicates that the operating point meets the steady state specification.
The Actual Value of the states falls within the Desired Value bounds.

(Optional) Click Generate MATLAB Code in the Trim drop-down list to automatically generate a MATLAB script.

The generated script will contain commands for computing the operating point for this example.
This example shows how to specify an output constraint of an engine speed for computing the engine steady-state operating point.
Open Simulink model.
sys = 'scdspeed'; open_system(sys)

In the Simulink model window, select Tools > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
Click Trim Model > Specifications in the Linear Analysis tab.
The Specifications for trim dialog appears.
Click Outputs to examine the outputs for scdspeed.

Currently there are no outputs specified for scdspeed.
In the Simulink model window, right-click the output signal from the rad/s to rpm block. Select Linearization Points > Output Constraint.
This action adds the output signal constraint marker to the model.

The output signal from the rad/s to rpm block now appears under the Outputs tab.

Select Known and enter 2000 RPM for the engine speed as the output signal value. Press Enter.

Click Trim in the Trim Model tab.
This action finds a new steady-state operating point that meets the specified output signal constraint.
Double click op_trim1 in Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.
In the States tab, the Actual dx values are either zero or effectively zero, the desired result, which indicates that the operating point meets the steady state specification.

In the Outputs tab, the Actual Value and the Desired Value are both 2000.

This example shows how to use the Linear Analysis Tool to initialize the values of a steady-state operating point search, or equilibrium operating point search, using a simulation snapshot.
If you know the approximate time when the model reaches the neighborhood of a steady-state operating point, you can use simulation to get the state values to be used as the initial condition for numerical optimization.
Open Simulink model.
sys = ('watertank');
open_system(sys)

In the Simulink model window, select Tools > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
Click Operating Point Snapshot in the Linear Analysis tab.
Enter 10 in the Simulation Snapshot Times field to extract the operating point at this simulation time. Press Enter.
Click Take Snapshots.

This action takes a snapshot of the system at the specified time. See op_snapshot1 in the Linear Analysis Workspace.
Click Trim Model > Specifications in the Linear Analysis tab to open the Specifications for trim dialog.
Click Import Initial Values.

This action opens the Import initial values dialog.
Select op_snapshot1 and click Import.

This action initializes the operating point states with the values you obtained from the simulation snapshot.

Click Trim in the Trim Model tab.
This action finds the optimized operating point using the states at t = 10 as the initial values.
Double click op_trim1 in Linear Analysis Workspace to evaluate whether the resulting operating point values meet the specifications.
The Actual dx values are near zero, the desired result, which indicates that the operating point meets the steady state specifications.

This example show how to use initopspec to initialize operating point object values for optimization-based operating point search.
Open Simulink model.
sys = 'watertank'; load_system(sys);
Extract an operating point from simulation after 10 time units.
opsim = findop(sys,10);
Create operating point specification object.
By default, all model states are specified to be at steady state.
opspec = operspec(sys);
Configure initial values for operating point search.
opspec = initopspec(opspec,opsim);
Find the steady state operating point that meets these specifications.
[op,opreport] = findop(sys,opspec) bdclose(sys);
opreport describes the optimization algorithm status at the end of the operating point search.
Operating 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: -1.1e-014 (0)
Inputs: None
----------
Outputs: None
----------dx, which is the time derivative of each state, is effectively zero. This value of the state derivative indicates that the operating point is at steady state.
This example shows how to compute the steady-state operating point of a SimMechanics model from specifications.
Open the SimMechanics model.
sys = 'scdmechconveyor'; open_system(sys)

Open the machine environment (Env) block parameters dialog box.
In the Parameters tab, set Analysis mode to Trimming. Click OK.

This action adds an output port to the model with constraints that must be satisfied to a ensure a consistent SimMechanics machine.
In the Simulink model window, select Tools > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
Click Trim Model > Specifications in the Linear Analysis tab to open the Specifications for trim dialog.
By default, all model states are specified to be at equilibrium (as shown in the Steady State column). The Outputs tab shows the error constraints in the system that must be set to zero for steady-state operating point search.
Select Known in the Outputs tab to set all constraints to 0.

You can now specify additional constraints on the operating point states and input levels, and find the steady-state operating point for this model.
After you finish steady-state operating point search for the SimMechanics model, reset the Analysis mode to Forward dynamics in the Env block parameters dialog box.
This example shows how to batch compute steady-state operating points for a model.
If you are new to writing scripts, use the Linear Analysis Tool to interactively configure your operating points search. You can use Simulink Control Design to automatically generate a script based on your Linear Analysis Tool settings.
Open Simulink model.
sys = 'magball'; open_system(sys)
In the Simulink model window, select Tools > Control Design > Linear Analysis.
The Linear Analysis Tool for the model opens.
Select Trim Model > Specifications in the Linear Analysis tab.
By default, all model states are specified to be at equilibrium (as shown in the Steady State column).
In the States tab, clear Steady State for the magball/Magnetic Ball Plant/height state.
This action removes the specification that the magnetic ball's height is at steady state.

Click Trim to compute the operating point using numerical optimization.
The Trim progress viewer shows that the optimization algorithm terminated successfully. The (Maximum Error) Block area shows the progress of reducing the error of a specific state or output during the optimization.
Click Generate MATLAB Code in the Trim drop-down list to automatically generate a MATLAB script.
The generated script appears in a MATLAB Editor window.
Edit the script:
Define initial height variable height with values at which to compute operating points.
Add a FOR-loop around the operating point search code to compute a steady-state operating point for each height value.
Note Remove unneeded comments and add a for loop around the optimization and change the initial height variable height to specify a different target operating point. |
Your script should now look similar to this (excluding most comments):
function [op,opreport] = myoperatingpointsearch
%% Specify the model name
sys = 'magball';
load_system(sys)
%% Create operating point specification object
opspec = operspec(sys)
% State (5) - magball/Magnetic Ball Plant/height
% - Default model initial conditions are used to initialize optimization.
opspec.States(5).SteadyState = false;
%% Create the options
opt = linoptions('DisplayReport','iter');
%% Specify the initial heights at which to compute operating points
height = [0.05;0.1;0.15];
%% Loop over height values to find the corresponding steady state
%% operating points
for ct = 1:numel(height)
% Set the initial height in the specification
opspec.States(5).x = height(ct);
% Trim the model
[op(ct),oprep(ct)] = findop(sys,opspec,opt);
end
This example shows how to control the accuracy of your operating point search by configuring the optimization algorithm.
Typically, you adjust the optimization settings based on the operating point search report, which is automatically created after each search.
In the Linear Analysis Tool, select Trim Model> Optimization Options in the Linear Analysis tab.
This action opens the Options for trim dialog box.

Change the appropriate optimization settings.
This table lists the most common optimization settings.
| Optimization Status | Option to Change | Comment |
|---|---|---|
| Optimization ends before completing (too few iterations) | Maximum iterations | Increase the number of iterations |
| State derivative or error in output constraint is too large | Function tolerance or Constraint tolerance (depending on selected algorithm) | Decrease the tolerance value |
![]() | Steady-State Operating Points From Specifications Versus Simulation | Steady-State Operating Points From Simulation | ![]() |

Learn more about resources for designing, testing, and implementing control systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |