变体分层组件
使用分层变体模块,您可以在单个模型中表示一个系统的所有设计备选方案。每个设计选择项都作为单独的层次结构中的一个变体选择项纳入模型中。这种模型有固定的通用结构和一组有限的可变组件,这些组件根据具体变体控制项而被激活或反激活。
例如,假设您要仿真一个车辆模型,该车辆具有三种可能的引擎配置:4 缸、6 缸和 8 缸。您可以将每个引擎模型实现为 Variant Subsystem, Variant Model, Variant Assembly Subsystem 模块中的一个单独子系统,然后根据您选择的变体控制项在子系统之间切换。有关详细信息,请参阅变体控制项简介。
为分层变体模块生成的代码可以包含一个系统的所有变体选择项。您可以在代码编译前或在模型启动时在选择项之间切换,如Activate Variant During Different Stages of Simulation and Code Generation Workflow中所述。有关使用分层变体模块生成代码的信息,请参阅变体结构 (Simulink Coder)。
模块
Variant Subsystem, Variant Model, Variant Assembly Subsystem | Template subsystem containing Subsystem, Model, or Subsystem Reference blocks as variant choices |
类
Simulink.VariantControl | Create a variant control variable object (自 R2021a 起) |
Simulink.Parameter | 存储、共享和配置参数值 |
Simulink.Variant | 指定控制变体选择的条件 |
Simulink.VariantUtils | Utility methods to work with variant elements (自 R2023b 起) |
函数
enumeration | 类枚举成员和名称 |
对象
struct | 结构体数组 |
主题
- Implement Variations in Separate Hierarchy Using Variant Subsystems
Learn basic functionality of variant subsystems.
- Variant Control Modes in Variant Blocks
Learn how to control variant blocks.
- Propagate Variant Conditions to Define Variant Regions with Variant Blocks
Determine active model components by propagating variant conditions using variant blocks.
- Propagate Variant Conditions to Define Variant Regions Outside Variant Subsystems
Propagate variant conditions outside a Variant Subsystem block to adapt its interface according to the state of underlying blocks.
- Propagate Variant Conditions to Control Execution of Conditional Subsystems
Understand how to use Variant Subsystem blocks with conditionally executed systems as variant choices.
- Add or Remove Variant Choices of Variant Assembly Subsystem Blocks Using External Files
Understand how to add or remove variant choices of the Variant Assembly Subsystem block using external files without modifying model.
- Control Variant Choices in Masked Variant Assembly Subsystem Block Using Mask Parameter Object
Specify variant choices and set an active choice in a masked Variant Assembly Subsystem block.
- Control Active Choice of Locked Custom Library Variant Subsystem Using Mask Parameter
Control active choice of Variant Subsystem that belongs to a locked custom library.
- Model Reference Variants
This example shows how to use model reference variants.
疑难解答
Convert Configurable Subsystem to Variant Subsystem
Learn how to convert configurable subsystems to variant subsystems and their behavior on loading.
Convert Variant Subsystem to Variant Assembly Subsystem
Steps to convert Variant Subsystem block to Variant Assembly Subsystem block.
Transform Model to Variant System (Simulink Check)
Use the Model Transformer tool to transform a model into a variant system.