updatePortsFromChoices
Update ports in Variant Component block to match its variant choices
Since R2024a
Description
updatePortsFromChoices(
aligns the ports of the Variant Component block
variantComponent
,Mode=portOption
)variantComponent
with the number and types of its variant choices using
a method specified by portOption
.
Examples
Input Arguments
Limitations
In a Variant Component 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 Component block, using the
updatePortsFromChoices
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 to update
diagram
.
More About
Tips
Use the updatePortsFromChoices
function for Variant
Component 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 Component block, the Variant Assembly Component
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 Component or Variant Assembly Component block by using the Fix It options in the Diagnostic Viewer window. When simulating a model with missing or unused ports in a Variant Component or Variant Assembly Component block, the error messages provide Fix It options to add missing ports and remove unused ports from the Variant Component or Variant Assembly Component block for proper alignment with the underlying variant choices.
Version History
Introduced in R2024a