Propagate Variant Conditions to Enable or Disable Model or Subsystem References in Hierarchy
Simulink® compiles referenced models before propagating variant conditions. A variant condition can activate or deactivate a Model block, but the variant condition does not propagate into the referenced model. Instead, it stays on the boundary. However, the blocks inside the referenced model inherit the variant condition from the Model block.
Explore the Model
Consider the slexVariantMdlRefCondProp
model.
open_system("slexVariantMdlRefCondProp")
In the model, the Variant Source1
block has a variant condition V == 1
that propagates to the Model block sub1
. Since sub1
is a Model block, the variant condition stays on the boundary and applies to the referenced model within the Model block. If sub1
is active, the blocks within sub1
are also active. If sub1
is inactive, the blocks within sub1
are also inactive, thus making sub1
conditional.
A Model block can propagate variant conditions from its interface (input, output, or control port), if those variant conditions originate at ports inside the block. In this example, the Model block sub2
propagates the variant conditions received from the referenced model slexVariantMdlRefCondProp_sub2
at the outports.
sim("slexVariantMdlRefCondProp");
Note
The Model block does not propagate variant conditions from its interface if those variant conditions originate from the Initialize Function or Terminate Function blocks inside the Model block. For more information, see Conditionally Execute Custom Initialize, Reinitialize, Reset, and Terminate Routines.
Create and Use Referenced Subsystems in Models blocks propagate the variant conditions in the same way as Model blocks.
Generate Code for Model Reference Blocks
For an example on how to generate code, see Generate Code for Model References Connected to Variant Blocks (Simulink Coder).
See Also
Propagate Variant Conditions to Define Variant Regions with Variant Blocks