Create Interchangeable Variations of Model Components
To make a model flexible and able to cater to different requirements, you can use variant subsystems and models. Variants allow you to choose among multiple variations of a component within a single model. To change the active variant without modifying the model, in the MATLAB® Command Window, change the values of variant control variables.
The model named BasicModelingVariants
includes three variant choices for the operator.
mdl = "BasicModelingVariants"; open_system(mdl) set_param(mdl,SimulationCommand="Update");
A Variant Subsystem block named Operator
contains the variant choices. Variant Subsystem blocks allow both subsystems and models as variant choices.
The Subsystem block named Operator1
is the active variant specified by the script named BasicModelingVariantChoice.m
. To determine the goal position for the plant, this operator implements procedural logic with a Stateflow® chart.
Inactive variants and their contents are grayed out. To define the goal position for the plant position, the inactive Subsystem block named Operator2
uses a Waveform Generator block.
To define the goal position for the plant position, the inactive Model block named Operator3
uses a Pulse Generator block.