Main Content

setxu

Set states and inputs in operating points

Syntax

op_new = setxu(op_point,x,u)

Description

setxu set state and input values for an operating point. Use this function for applications that require state and input values to be specified in vector format, such as when using an operating in an optimization problem using fmincon.

op_new = setxu(op_point,x,u) returns a new operating point with the specified state and input values (x and u, respectively). Specify x as either a vector or structure with the same format as those returned from a Simulink® simulation. Specifying x as a structure with time is not supported. Specify u as a vector. You can obtain both x and u from another operating point object with the getxu function.

Examples

collapse all

Export state values from a simulation and use the exported values to initialize an operating point object.

Open the Simulink model. This example uses the model scdplane.

mdl = 'scdplane';
open_system(mdl)

You can save the final states of the model to the workspace after a simulation. In the Simulink editor, on the Modeling tab, click Model Settings. Then, in the Configuration Parameters dialog box, select the Final states parameter.

Simulate the model. After the simulation, the xFinal variable appears in the workspace. This variable is a vector containing the final state values.

sim(mdl)

Create an operating point object for scdplane.

op_point = operpoint(mdl)
 Operating Point for the Model scdplane.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
(1.) scdplane/Actuator Model
      x: 0            
(2.) scdplane/Aircraft Dynamics Model/Transfer Fcn.1
      x: 0            
(3.) scdplane/Aircraft Dynamics Model/Transfer Fcn.2
      x: 0            
(4.) scdplane/Controller/Alpha-sensor Low-pass Filter
      x: 0            
(5.) scdplane/Controller/Pitch Rate Lead Filter
      x: 0            
(6.) scdplane/Controller/Proportional plus integral compensator
      x: 0            
(7.) scdplane/Controller/Stick Prefilter
      x: 0            
(8.) scdplane/Dryden Wind Gust Models/Q-gust model
      x: 0            
(9.) scdplane/Dryden Wind Gust Models/W-gust model
      x: 0            
      x: 0            

Inputs: 
----------
(1.) scdplane/u
      u: 0    

All states are initially set to 0.

Initialize the states in the operating point object to the values in xFinal. Set the input to be 9.

newop = setxu(op_point,xFinal,9)
 Operating Point for the Model scdplane.
 (Time-Varying Components Evaluated at time t=0)

States: 
----------
(1.) scdplane/Actuator Model
      x: -0.032       
(2.) scdplane/Aircraft Dynamics Model/Transfer Fcn.1
      x: 0.56         
(3.) scdplane/Aircraft Dynamics Model/Transfer Fcn.2
      x: 678          
(4.) scdplane/Controller/Alpha-sensor Low-pass Filter
      x: 0.392        
(5.) scdplane/Controller/Pitch Rate Lead Filter
      x: 0.133        
(6.) scdplane/Controller/Proportional plus integral compensator
      x: 0.166        
(7.) scdplane/Controller/Stick Prefilter
      x: 0.1          
(8.) scdplane/Dryden Wind Gust Models/Q-gust model
      x: 0.114        
(9.) scdplane/Dryden Wind Gust Models/W-gust model
      x: 0.46         
      x: -2.05        

Inputs: 
----------
(1.) scdplane/u
      u: 9    

Alternatives

As an alternative to the setxu function, set states and inputs of operating points using the Model Linearizer app.

Version History

Introduced before R2006a