主要内容

clone

复制 Stateflow 图的工作点

    说明

    newOp = clone(op) 为 Stateflow® 图创建工作点 op 的副本。

    示例

    示例

    全部折叠

    1. 打开 sf_car 模型。

      openExample("sf_car")

      有关此模型的详细信息,请参阅Model a Car with Automatic Transmission

    2. 设置模型以保存最终工作点。打开“配置参数”对话框,并在数据导入/导出窗格中执行以下操作:

      1. 选择最终状态并输入工作点的名称。对于此示例,请使用 xFinal

      2. 选择保存最终工作点

      3. 点击确定

    3. 设置此仿真段的停止时间。在仿真选项卡中,将停止时间设置为 10

    4. 运行仿真。

    5. 访问包含 shift_logic 图的工作点信息的 Stateflow.op.BlockOperatingPoint 对象。

      blockpath = "sf_car/shift_logic";
      op = get(xFinal,blockpath);
    6. 访问包含 gear_state 状态的工作点信息的 Stateflow.op.OperatingPointContainer 对象。

      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)"                 
      

      工作点显示子状态 second 被激活。

    7. 创建工作点的一个副本。

      newOp = clone(op);
    8. 通过更改 gear_state 的激活子状态修改新工作点。

      setActive(newOp.gear_state.first)

    9. 验证子状态 first 在修改后的工作点中被激活。

      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. 验证子状态 second 在原始工作点中被激活。

      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)"                 
      

    输入参数

    全部折叠

    Stateflow 图的工作点,指定为 Stateflow.op.BlockOperatingPoint 对象。

    输出参量

    全部折叠

    工作点的副本,以 Stateflow.op.BlockOperatingPoint 对象形式返回。

    版本历史记录

    在 R2009b 中推出