Main Content

getPrevActiveChild

Get previously active substate

    Description

    example

    substateOp = getPrevActiveChild(stateOp) returns the operating point for the previously active substate in the operating point stateOp. stateOp must be an operating point for a state that contains a history junction.

    Examples

    collapse all

    1. Open the sf_boiler model.

      openExample("stateflow/BangBangControlUsingTemporalLogicExample")

      For more information about this model, see Model Bang-Bang Temperature 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 xFinal.

      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 100.

    4. Run the simulation.

    5. Access the Stateflow.op.BlockOperatingPoint object that contains the operating point information for the Bang-Bang Controller chart.

      blockpath = "sf_boiler/Bang-Bang Controller";
      op = get(xFinal,blockpath);
    6. Verify that the state On in the box Heater is not active.

      isActive(op.Heater.On)
      ans =
      
        logical
      
         0
      
    7. Find the previously active substate of state On.

      getPrevActiveChild(op.Heater.On)
      ans = 
      
      State: "HIGH"    (handle)
        Path:     sf_boiler/Bang-Bang Controller/Heater/On/HIGH
      
        Contains:
      
          []
      
    8. Modify the previously active substate of state On. Specify the substate as a Stateflow.op.OperatingPointContainer object.

      setPrevActiveChild(op.Heater.On,op.Heater.On.NORM)
      Alternatively, specify the name of the substate by using a string scalar or a character vector.
      setPrevActiveChild(op.Heater.On,"NORM")

    9. Verify that the substate NORM is the previously active substate in the modified operating point.

      getPrevActiveChild(op.Heater.On)
      ans = 
      
      State: "NORM"    (handle)
        Path:     sf_boiler/Bang-Bang Controller/Heater/On/NORM
      
        Contains:
      
          []

    Input Arguments

    collapse all

    Operating point for a state that contains a history junction, specified as a Stateflow.op.OperatingPointContainer object.

    Output Arguments

    collapse all

    Operating point for the previously active substate, returned as a Stateflow.op.OperatingPointContainer object.

    Version History

    Introduced in R2009b