MATLAB Examples

Compute Operating Point from Output Specifications at Command Line

This example shows how to compute a steady-state operating point by specifying known output values and constraints.

Open the Simulink model.

mdl = 'scdspeed';
open_system(mdl)

Create a default operating point specification for the model.

opspec = operspec(mdl)
 Operating point specification for the Model scdspeed.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
	 spec:  dx = 0,  initial guess: 0.543
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
	 spec:  dx = 0,  initial guess: 209

Inputs: 
----------
(1.) scdspeed/Throttle  perturbation
	 initial guess: 0            

Outputs: None 
----------


Since there are no root-level outputs in the model, the default operating point specification object has no output specifications.

For this example, specify a known steady-state engine speed. To do so, add an output specification at the output of the rad/s to rpm block.

opspec = addoutputspec(opspec,'scdspeed/rad//s to rpm',1);

Specify a known value of 2000 rpm for the output constraint.

opspec.Outputs(1).Known = 1;
opspec.Outputs(1).y = 2000;

View the updated operating point specification.

opspec
 Operating point specification for the Model scdspeed.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
	 spec:  dx = 0,  initial guess: 0.543
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
	 spec:  dx = 0,  initial guess: 209

Inputs: 
----------
(1.) scdspeed/Throttle  perturbation
	 initial guess: 0            

Outputs: 
----------
(1.) scdspeed/rad//s to rpm
	 spec:  y = 2e+03        


Find an operating point that meets these specifications.

op1 = findop(mdl,opspec);
 Operating point search report:
---------------------------------

 Operating point search report for the Model scdspeed.
 (Time-Varying Components Evaluated at time t=0)

Operating point specifications were successfully met.
States: 
----------
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
      x:         0.544      dx:      2.66e-13 (0)
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
      x:           209      dx:     -8.48e-12 (0)

Inputs: 
----------
(1.) scdspeed/Throttle  perturbation
      u:       0.00382    [-Inf Inf]

Outputs: 
----------
(1.) scdspeed/rad//s to rpm
      y:         2e+03    (2e+03)

The operating point search report shows that the specifications were met successfully, and that both states are at steady state as expected (dx = 0).

You can also specify bounds for outputs during trimming. For example, suppose that you know that there is a steady-state condition between 1900 and 2100 rpm. To trim the speed to this range, modify the operating point specifications.

opspec.Outputs(1).Min = 1900;
opspec.Outputs(1).Max = 2100;

In this case, since you do not know the output value, specify the output as unknown. You can also provide an initial guess for the output value.

opspec.Outputs(1).Known = 0;
opspec.Outputs(1).y = 2050;

Find an operating point that meets these specifications.

op2 = findop(mdl,opspec);
 Operating point search report:
---------------------------------

 Operating point search report for the Model scdspeed.
 (Time-Varying Components Evaluated at time t=0)

Operating point specifications were successfully met.
States: 
----------
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
      x:         0.544      dx:      2.99e-13 (0)
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
      x:           209      dx:      -9.9e-13 (0)

Inputs: 
----------
(1.) scdspeed/Throttle  perturbation
      u:         0.005    [-Inf Inf]

Outputs: 
----------
(1.) scdspeed/rad//s to rpm
      y:         2e+03    [1.9e+03 2.1e+03]

The operating point search report shows that the specifications were met successfully.