Main Content

Compute Operating Points from Specifications at the Command Line

You can compute a steady-state operating point of a Simulink® model by specifying constraints on the model states, outputs, and inputs, and by finding a model operating condition that satisfies these constraints. For more information on steady-state operating points, see About Operating Points and Compute Steady-State Operating Points.

To find an operating point for your Simulink model, you can programmatically trim your model using the findop, as shown in this example.

Alternatively, you can trim your model in the:

In this example, you compute an operating point to meet output specifications. Using a similar approach, you can define state or input specifications. Also, you can define a combination of state, output, and input specifications; that is, you do not have to use, for example, only state specifications.

For more information on trimming your model to meet specifications, see Compute Steady-State Operating Points from Specifications.

Open Simulink Model

Open the Simulink model.

mdl = 'scdspeed';
open_system(mdl)

Define Operating Point Specifications

Create a default operating point specification for the model.

opspec = operspec(mdl)
opspec = 


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

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
   0.543       false       true        -Inf         Inf        -Inf         Inf    
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
  209.48       false       true        -Inf         Inf        -Inf         Inf    

Inputs: 
----------
  u   Known  Min   Max 
_____ _____ _____ _____
                       
(1.) scdspeed/Throttle  perturbation
  0   false -Inf   Inf 

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
opspec = 


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

States: 
----------
     x         Known    SteadyState     Min         Max        dxMin       dxMax   
___________ ___________ ___________ ___________ ___________ ___________ ___________
                                                                                   
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
   0.543       false       true        -Inf         Inf        -Inf         Inf    
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
  209.48       false       true        -Inf         Inf        -Inf         Inf    

Inputs: 
----------
  u   Known  Min   Max 
_____ _____ _____ _____
                       
(1.) scdspeed/Throttle  perturbation
  0   false -Inf   Inf 

Outputs: 
----------
  y   Known  Min   Max 
_____ _____ _____ _____
                       
(1.) scdspeed/rad//s to rpm
2000  true  -Inf   Inf 

Trim Model

Find an operating point that meets these specifications.

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

opreport = 


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

Operating point specifications were successfully met.
States: 
----------
    Min          x          Max        dxMin        dx         dxMax   
___________ ___________ ___________ ___________ ___________ ___________
                                                                       
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
   -Inf       0.54363       Inf          0      2.6649e-13       0     
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
   -Inf      209.4395       Inf          0      -8.4758e-12      0     

Inputs: 
----------
   Min        u        Max   
_________ _________ _________
                             
(1.) scdspeed/Throttle  perturbation
  -Inf    0.0038183    Inf   

Outputs: 
----------
Min   y   Max 
____ ____ ____
              
(1.) scdspeed/rad//s to rpm
2000 2000 2000

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:
---------------------------------

opreport = 


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

Operating point specifications were successfully met.
States: 
----------
    Min          x          Max        dxMin        dx         dxMax   
___________ ___________ ___________ ___________ ___________ ___________
                                                                       
(1.) scdspeed/Throttle & Manifold/Intake Manifold/p0 = 0.543 bar
   -Inf       0.5436        Inf          0      2.9879e-13       0     
(2.) scdspeed/Vehicle Dynamics/w = T//J w0 = 209 rad//s
   -Inf      209.4799       Inf          0      -9.8968e-13      0     

Inputs: 
----------
   Min        u        Max   
_________ _________ _________
                             
(1.) scdspeed/Throttle  perturbation
  -Inf    0.0050021    Inf   

Outputs: 
----------
   Min        y        Max   
_________ _________ _________
                             
(1.) scdspeed/rad//s to rpm
  1900    2000.3853   2100   

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

After trimming your model, you can:

See Also

| |

Related Topics