Main Content

getxu

States and inputs from operating points

Syntax

x = getxu(op)
[x,u] = getxu(op)
[x,u,xstruct] = getxu(op)

Description

getxu extracts state and input values from 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.

Note

Do not use getxu when setting initial state and input values using the Data Import/Export pane of the Configuration Parameters dialog box. Instead, use getstatestruct and getinputstruct.

x = getxu(op) extracts a vector of state values, x, from operating point, op.

[x,u] = getxu(op) also extracts a vector of input values, u, from the operating point. The ordering of inputs in u corresponds to the root-level input port numbering in Simulink®.

[x,u,xstruct] = getxu(op) also extracts a structure of state values, xstruct, from the operating point. The structure of state values, xstruct, has the same format as that returned from a Simulink simulation.

Examples

collapse all

Create an operating point for the magball model.

op = operpoint('magball');

View the states in the operating point.

op.States
ans = 
   x   
_______
       
(1.) magball/Controller/PID Controller/Filter/Cont. Filter/Filter
   0   
(2.) magball/Controller/PID Controller/Integrator/Continuous/Integrator
14.0071
(3.) magball/Magnetic Ball Plant/Current
7.0036 
(4.) magball/Magnetic Ball Plant/dhdt
   0   
(5.) magball/Magnetic Ball Plant/height
 0.05  

Extract vectors of state and input values and a state structure from the operating point.

[x,u,xstruct] = getxu(op)
x = 5×1

         0
   14.0071
    7.0036
         0
    0.0500

u =

     []
xstruct = struct with fields:
       time: 0
    signals: [1x5 struct]

View the states within the state structure.

xstruct.signals
ans=1×5 struct array with fields:
    values
    dimensions
    label
    blockName
    stateName
    inReferencedModel
    sampleTime

The values field shows the state values for the operating point. The blockName field shows the names of the block that contain each state.

Version History

Introduced before R2006a