Simulink.VariantUtils.updateVariantSubsystemPorts
Update ports in Variant Subsystem block to match its variant choices
Since R2024a
Description
Simulink.VariantUtils.updateVariantSubsystemPorts(
aligns the ports of the Variant Subsystem block
blockPathOrHandle
,Mode=portOption
)blockPathOrHandle
with the number and types of its variant choices
using a method specified by portOption
.
Examples
Input Arguments
Limitations
In a Variant Subsystem block, each control port must be unique and have a distinct type when the Variant activation time parameter is set to an activation time other than
update diagram
. If the variant choices have two different control ports of the same type, and those ports are missing in the Variant Subsystem block, using theSimulink.VariantUtils.updateVariantSubsystemPorts
function attempts to add both the missing control ports. However, this results in a simulation error. Therefore, if you need to add multiple control ports of the same type in the Variant Subsystem block, you must change the Variant activation time parameter toupdate diagram
.The
Simulink.VariantUtils.updateVariantSubsystemPorts
function cannot be used on a Variant Subsystem block when it is within a locked library, is a linked block, or is nested within a linked block whose top-level block is not configured for self-modification. This restriction ensures that updates to variant subsystem ports adhere to the structural integrity of locked or non-modifiable libraries. For more information, see Self-Modifiable Linked Subsystems.
Tips
Use the Simulink.VariantUtils.updateVariantSubsystemPorts
function
for Variant Subsystem blocks with the Allow flexible
interface parameter set to on
. This setting allows variations
in the number of ports between the block and its variant choices, ensuring relevant automated
port synchronization. Unlike the Variant Subsystem block, the Variant
Assembly Subsystem block does not enforce a strict set of ports. Therefore, you can
use this function without any additional configuration.
Alternative Functionality
You can align ports in a Variant Subsystem or Variant Assembly Subsystem block by using the Fix It options in the Diagnostic Viewer window. When simulating a model with missing or unused ports in a Variant Subsystem or Variant Assembly Subsystem block, the error messages provide Fix It options to add missing ports and remove unused ports from the Variant Subsystem or Variant Assembly Subsystem block for proper alignment with the underlying variant choices.
Version History
Introduced in R2024a