Main Content

clone

Copy operating point for Stateflow chart

    Description

    newOp = clone(op) creates a copy of the operating point op for a Stateflow® chart.

    example

    Examples

    collapse all

    1. Open the sf_car model.

      openExample("sf_car")

      For more information about this model, see Simulate Chart as a Simulink Block with Local Events.

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

    4. Run the simulation.

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

      blockpath = "sf_car/shift_logic";
      op = get(xFinal,blockpath);
    6. Access the Stateflow.op.OperatingPointContainer object that contains the operating point information for the gear_state state.

      op.gear_state
      ans = 
      
      State: "gear_state"    (handle)    (active)
        Path:     sf_car/shift_logic/gear_state
      
        Contains:
      
          + first          "State (OR)"                 
          + fourth         "State (OR)"                 
          + second         "State (OR)"         (active)
          + third          "State (OR)"                 
      

      The operating point shows that the substate second is active.

    7. Create a copy of the operating point.

      newOp = clone(op);
    8. Modify the new operating point by changing the active substate of gear_state.

      setActive(newOp.gear_state.first)

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

      newOp.gear_state
      ans = 
      
      State: "gear_state"    (handle)    (active)
        Path:     sf_car/shift_logic/gear_state
      
        Contains:
      
          + first          "State (OR)"         (active)                 
          + fourth         "State (OR)"                 
          + second         "State (OR)"
          + third          "State (OR)"                 
      

    10. Verify that the substate second is active in the original operating point.

      op.gear_state
      ans = 
      
      State: "gear_state"    (handle)    (active)
        Path:     sf_car/shift_logic/gear_state
      
        Contains:
      
          + first          "State (OR)"                 
          + fourth         "State (OR)"                 
          + second         "State (OR)"         (active)
          + third          "State (OR)"                 
      

    Input Arguments

    collapse all

    Operating point for a Stateflow chart, specified as a Stateflow.op.BlockOperatingPoint object.

    Output Arguments

    collapse all

    Copy of operating point, returned as a Stateflow.op.BlockOperatingPoint object.

    Version History

    Introduced in R2009b