Main Content

setPrevActiveChild

Set previously active substate

    Description

    setPrevActiveChild(stateOp,substateOp) sets the state that corresponds to the operating point substateOp as the previously active substate in the operating point stateOp. stateOp must be an operating point for an inactive state that contains a history junction.

    example

    setPrevActiveChild(stateOp,substateName) marks the state called substateName as the previously active substate in stateOp.

    example

    Examples

    collapse all

    1. Open the sf_boiler model.

      openExample("sf_boiler")

      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 an inactive state that contains a history junction, specified as a Stateflow.op.OperatingPointContainer object.

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

    Name of the new previously active substate, specified as a string scalar or a character vector.

    Version History

    Introduced in R2009b