Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

模型引用

将模型作为模块重用于其他模型

模型引用是对使用 Model 模块的另一个模型的引用。这些引用会创建模型层次结构。每个引用模型都有一个定义的接口,该接口指定其输入和输出的属性。定义的接口使得引用模型的行为独立于它在模型层次结构中的上下文。模型引用非常适合代码重用、单元测试、并行编译和大型组件。它们还可以减少文件争用和合并问题。

要确定引用模型是否满足您的建模需求,请参阅基于组件的建模规范

要了解模型引用层次结构的代码生成,请参阅引用模型 (Simulink Coder)

要创建受保护模型,请参阅模型保护 (Simulink Coder)

要对模型引用层次结构执行 SIL/PIL 测试,请参阅SIL 和 PIL 仿真 (Embedded Coder)

模块

Model引用另一个模型来创建模型层次结构
Variant ModelTemplate subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices

函数

全部展开

depview分析和可视化模型引用依存关系,可包括或不包括库依存关系
find_mdlrefs在模型层次结构中查找引用模型和 Model 模块
pathsToReferencedModelModel hierarchy path composed of referenced models and Model blocks (自 R2023b 起)
Simulink.BlockDiagram.refreshBlocksUpdate variants, linked blocks, and model references to reflect changes (自 R2023a 起)
Simulink.BlockPathFully specified Simulink block path
Simulink.fileGenControl为图更新和模型编译生成的文件指定根文件夹
Simulink.ModelReference.refreshForce update to Model block to reflect changes to referenced model (自 R2020a 起)
Simulink.SubSystem.convertToModelReference将子系统转换为模型引用
slbuild为模型编译独立可执行文件或模型引用目标
slxcinfoQuery contents of Simulink cache files (自 R2020b 起)
slxcunpackUnpack simulation and code generation targets from Simulink cache file (自 R2020b 起)
Simulink.ProtectedModel.createHarnessCreate harness model that provides isolated environment for testing protected model (自 R2020b 起)
Simulink.ProtectedModel.getPublisherReturn information about publisher that signed the protected model (自 R2020a 起)
Simulink.ProtectedModel.verifySignatureVerify digital signature on protected model (自 R2020a 起)
Simulink.ProtectedModel.suppressSignatureVerificationSuppress digital signature verification of protected models (自 R2020b 起)

模型设置

全部展开

重新编译有条件地、始终或从不重新编译模型引用目标的选项
从不重新编译诊断Diagnostic action to take when model reference target must be rebuilt
启用并行模型引用编译Option to build a model reference hierarchy in parallel whenever possible
MATLAB 工作进程的编译初始化Options for how to initialize MATLAB workers for parallel builds
为引用模型启用严格调度检查Option to check consistency of scheduling and sample time in referenced models
每个顶层模型允许的实例总数Number of references to this model that can occur in another model
传播可变大小信号的大小Option to specify how variable-size signals propagate through referenced models
尽量减少出现代数环Option to try to eliminate artificial algebraic loops related to referenced model
将所有信号标签传播到模型之外Option to pass propagated signal names out of referenced model
引用模型时使用局部求解器Option to use local solver to solve referenced model as separate system of equations (自 R2022a 起)
模型依存关系User-created files and data that potentially impact simulation results
对并行池执行一致性检查Option to perform checks on parallel pool before starting parallel build (自 R2021a 起)
包含引用模型的自定义代码Option to use custom code in model reference simulation target
为代码生成按值传递固定大小的标量根输入Option to pass scalar input to model by reference or value
Model 模块版本不匹配Diagnostic action to take when Model block does not represent current version of referenced model
端口和参数不匹配Diagnostic action to take when port or parameter does not match between Model block and referenced model
不支持的数据记录Diagnostic action to take when data logging is unsupported
模型参数没有显式最终值Diagnostic action to take for model argument with default value at top-level model reference (自 R2020b 起)

工具

模型引用转换顾问Convert subsystems to referenced models
引用的文件窗格View, save, and close referenced subsystems and models (自 R2020b 起)

主题

确定何时引用模型

  • 基于组件的建模规范
    考虑大型模型和多用户开发团队的组件化。
  • 模型引用基础知识
    通过在一个模型中引用另一个模型可以创建模型层次结构。引用模型中包含多个模块,这些模块作为一个单元一起执行。
  • 模型引用的要求和限制
    模型引用在可重用性、仿真模式、封装和调试等功能方面有一定的要求和限制。

创建模型引用

配置模型引用

仿真模型层次结构

相关信息