Main Content

重构模型以改善组件重复使用

您可以使用仪表盘指标来识别克隆es across a model hierarchy. Clones are identical MATLAB Function blocks, identical Stateflow charts, and subsystems that have identical block types and connections. Clones can have different parameter settings and values. To replace clones with links to library blocks, you can open the Clone Detector app from the Metrics Dashboard.

Use the Clone Detector app to refactor a model, improve model componentization and readability, and reuse components within a model. In this example, you launch the Clone Detector from the Metrics Dashboard. However, you can also open it by opening the应用标签和单击克隆探测器

Identify and Replace Clones with Links to Library Blocks

  1. In the建筑学部分,实际重复使用小部件中的蓝条指示链接的库块的子组件总数的比例。停下来实际重复使用小部件以查看更多信息。对于此模型,子组件总数的10%是链接的库块。

  2. To see more details, click the blue bar.系统滞后,,,,油门命令,,,,andcheckrange是链接的库块。

  3. Return to the main dashboard page.

  4. In the建筑学部分,潜在的重用bar indicates that the model contains clones. Pause over潜在的重用。对于此模型,7%的子组件是克隆。

  5. 要查看更多详细信息,请单击黄色条。压力。map_estimateand油门。Throttle_estimate是彼此的克隆。

  6. 要确定这些克隆是否是候选链接库块替换的候选者,请单击打开转换工具

    克隆探测器app opens as a new tab in the model.

  7. In theClone Detection Actions and Resultspane, click theMap Clone Groups to Library标签。

    有一个克隆组。浅蓝色阴影表明这些克隆是相似的克隆,而不是精确的克隆。相似的克隆具有不同的参数设置和值。

  8. 扩展克隆组。

    该克隆组由两个子图组成。

  9. 确定参数差异,在块差异列,单击查看参数差异

    此克隆组调用Simulink函数中的子图仅因其内部查找表块中的断点参数的值而差金宝app异。

  10. In theMap Clone Groups to Library标签,用于Library to place clones参数,使用Browse按钮选择库或指定新的库名称。如果指定新库名称,则该应用程序将创建库。

  11. Save the model to your working folder and, in the克隆探测器选项卡,单击Replace Clones。如果可能的话,该应用程序用指向蒙版库子系统的链接替换了类似的克隆。

    In theLogs选项卡,单击最新日志。

    该日志包含一条消息,表明无法用链接的库块替换克隆,因为Simulink函数中的数据不能促进到子曲目数据。金宝app

  12. 关闭the Metrics Dashboard and the model.

When the Clone Detector app refactors a model to replace clones with links to library blocks, the app creates a backup folder. The backup folder name has the prefixm2m_<模型名称>。如果你有金宝app®Test™license, you can verify the equivalency of the refactored and original models by clicking检查等效性in the克隆探测器标签。

探索其他选项

该表包含一个可以使用Simulink检查的常见任务列表。金宝app

Task 参考

简化和调试复杂模型。

突出显示功能依赖性

Run Model Advisor checks for compliance with safety standards associated with High-Integrity System Modeling and MAB Control Algorithm Modeling guidelines.

Check Model Compliance by Using the Model Advisor
Write custom Model Advisor checks. Define Your Own Custom Model Advisor Checks
创建和部署自定义模型顾问配置。 创建和部署模型顾问自定义配置and使用模型顾问配置编辑器自定义模型顾问

了解有关使用指标仪表板收集和查看度量数据以进行质量评估的更多信息。

使用指标仪表板收集和探索度量数据
Configure compliance metrics, add metric thresholds, and customize the Metrics Dashboard layout. 自定义指标仪表板布局和功能

使用模型变压器工具和克隆检测器应用程序来重构模型,以改善模型组件化和可读性并启用重复使用。

转换模型到变体系统and通过使用克隆检测启用组件重复使用
了解有关如何使用Simulink产品测试模型和代码,检金宝app查设计错误,根据标下载188bet金宝搏准检查,测量覆盖范围并验证系统的更多信息。 Verification and Validation