Main Content


Set state as active



    setActive(stateOp) sets the state that corresponds to the operating point stateOp as active. stateOp must be an operating point for a leaf state. When you call setActive, the chart maintains state consistency by:

    • Exiting and entering the appropriate states

    • Resetting temporal counters for newly active states

    • Updating values of active state data

    • Enabling or disabling function-call subsystems and Simulink® functions that bind to states

    However, the chart does not perform exit actions for the previously active states or entry actions for the newly active state. Additionally, the state does not reinitialize any state-parented local data.


    collapse all

    1. Open the sf_aircraft model.


      For more information about this model, see Detect Faults in Aircraft Elevator Control System.

    2. Set the model to save the final operating point. Open the Configuration Parameters dialog box and, in the Data Import/Export pane:

      1. Select Final states and enter a name for the operating point. For this example, use xSteadyState.

      2. Select Save final operating point.

      3. Click OK.

    3. Set the stop time for this simulation segment. In the Simulation tab, set Stop Time to 3.

    4. Run the simulation.

    5. Access the Stateflow.op.BlockOperatingPoint object that contains the operating point information for the Mode Logic chart.

      blockpath = "sf_aircraft/Mode Logic";
      op = get(xSteadyState,blockpath)
      op = 
        Block:    "Mode Logic"    (handle)    (active)
        Path:     sf_aircraft/Mode Logic
          + Actuators          "State (OR)"                    (active)
          + LI_act             "Function"
          + LO_act             "Function"
          + L_switch           "Function"
          + RI_act             "Function"
          + RO_act             "Function"
          + R_switch           "Function"
            LI_mode            "State output data"		sf_aircraft_ModeType [1,1]
            LO_mode            "State output data"		sf_aircraft_ModeType [1,1]
            RI_mode            "State output data"		sf_aircraft_ModeType [1,1]
            RO_mode            "State output data"		sf_aircraft_ModeType [1,1]
    6. Access the Stateflow.op.OperatingPointContainer object that contains the operating point information for the Actuators state.

      ans = 
        State:    "Actuators"    (handle)    (active)
        Path:     sf_aircraft/Mode Logic/Actuators
          + LI            "State (AND)"         (active)
          + LO            "State (AND)"         (active)
          + RI            "State (AND)"         (active)
          + RO            "State (AND)"         (active)
    7. Highlight the states that are active in the chart at t = 3.


      Stateflow chart showing active states.

    8. Change the substate activity in the state LO to reflect a failure of the left-outer actuator.


      Stateflow chart showing active states.

    9. Verify that the substate Isolated in the state LO is active in the modified operating point.

      ans =

    10. Remove the highlighting of active states in the Stateflow® Editor.


    Input Arguments

    collapse all

    Operating point for a leaf state, specified as a Stateflow.op.OperatingPointContainer object.

    Version History

    Introduced in R2009b