主要内容

本页采用了机器翻译。点击此处可查看英文原文。

重构模型

识别建模克隆件和模式以变换模型

使用模型变换器和克隆件检测器来重构模型,以改善模型组件化、可读性和可重用性。

使用模型变换器可以:

  • 确定可转换为 Variant Source 或 Variant Subsystem 模块的建模模式。使用 Variant SubsystemVariant Source 模块有助于提高模型在不同条件表达式(称为变体选择项)中的重用率。活动模型是根据所选的变体选择项而激活的固定结构和可变组件的组合。

  • 标识符合消除条件的数据存储模块。消除数据存储模块可明确显示数据依赖关系,从而提高模型的可读性。

  • 识别哪些 n-D Lookup Table 模块可转换为共享 Prelookup 模块和多个 Interpolation 模块。这种转换可提高仿真效率。

  • 识别在建模模式中可变换为单一 Interpolation Using Prelookup 模块的多个 Interpolation Using Prelookup 模块。这种变换可提高生成代码的效率。

  • 识别哪些 Bus CreatorBus Selector 模块可转换为 In Bus ElementOut Bus Element 模块。此转换可简化总线处理,减少模型中的模块数量并改善可读性。

使用克隆检测器可以:

  • 识别克隆件并创建模型,用指向库中子系统模块的链接替换克隆件。用指向库模块的链接替换克隆件可以实现组件重用并确保模型间的一致性。

  • 识别模型中的克隆并用子系统引用替换。

函数

全部展开

mdltransformer打开模型变换器
Simulink.ModelTransform.BusTransformation.identify识别需要变换的 Bus Selector 和 Bus Creator 模块 (自 R2022b 起)
Simulink.ModelTransform.BusTransformation.refactor将 Bus Selector 和 Bus Creator 模块替换为 In Bus Element 和 Out Bus Element 模块 (自 R2022b 起)
Simulink.ModelTransform.CommonSourceInterpolation.identifyCandidates识别符合条件的 Interpolation Using Prelookup 块以进行转换 (自 R2021b 起)
Simulink.ModelTransform.CommonSourceInterpolation.refactorModel替换 Interpolation Using Prelookup 块 (自 R2021b 起)
clonedetection打开克隆检测器
Simulink.CloneDetection.findClones查找模型中的克隆
Simulink.CloneDetection.replaceClones替换模型中的克隆
Simulink.CloneDetection.checkEquivalency检查克隆被替换后的模型与原始模型的等效性
Simulink.CloneDetection.highlightClone突出显示 Simulink 模型中的克隆 (自 R2021b 起)
Simulink.CloneDetection.generateReport生成克隆检测报告 (自 R2023b 起)
Simulink.CloneDetection.addExclusions从克隆检测中排除组件 (自 R2025a 起)
Simulink.CloneDetection.getExclusions获取从克隆检测中排除的组件列表 (自 R2025a 起)
Simulink.CloneDetection.deleteExclusions从克隆检测排除列表中移除组件 (自 R2025a 起)

全部展开

Simulink.ModelTransform.BusTransformation.Result已识别的总线选择器和 Bus Creator 模块的结果 (自 R2022b 起)
Simulink.ModelTransform.CommonSourceInterpolation.Results符合条件的 Interpolation Using Prelookup 模块的搜索结果 (自 R2021b 起)
Simulink.ModelTransform.CommonSourceInterpolation.RefactorResults重构模型结果 (自 R2021b 起)

主题

模型变换器

克隆件检测器

精选示例