Variant Connector
Libraries:
Simscape /
Utilities
Description
The Variant Connector block lets you define variant choices
in a physical network. Variant choices allow you to exclude some components from simulation
without physically removing the components from the physical network. The components to be
disconnected must be connected to the port associated with condition data. During simulation,
the variant condition is propagated to all the connected components within the physical
network. If the variant control associated with the block evaluates to
true
, all the components that are connected to the block become active. If
the variant control evaluates to false
, all the components connected to the
block become inactive.
Examples
Variant Leaf Region in Mechanical System
Simulate the displacement of velocity sources and mass by using the leaf type of the Variant Connector block. The leaf Variant Connector block forms a leaf region that allows you to vary the displacement during simulation.
Variant Bounded Region in Electrical Circuit
Activate or deactivate the flow of a current to a set of components in an electrical circuit by using the primary and nonprimary type Variant Connector blocks. The primary and nonprimary Variant Connector blocks form a bounded region that allows you to vary the electrical circuit during simulation.
Variant Connector Block with Simscape Bus Block
Use Variant Connector blocks with the Simscape Bus block.
Mask Workspace Variable in Variant Connector Block
Use a mask workspace variable as a variant control variable in a Variant Connector block.
Limitations
The Variant Connector block does not propagate the variant condition across the boundary between the Simscape™ physical network and the Simulink® blocks connected to it. In other words, if a block has both conserving ports and Simulink signal ports, such as a Simulink-PS Converter, a PS-Simulink Converter block, or a Subsystem block, the Variant Connector block stops propagating the variant condition at the boundary of that block. The condition is not propagated to any of its connected blocks. For more information, see Variant Condition Propagation From Variant Connector Block to Subsystem Block.
Ports
Conserving
Port_1 — Condition port
untyped conserving port
This port is located on the left side of the block and is labeled with a
rectangle. During simulation, if the variant choice associated with the block
evaluates to true
, all the components that are connected to this
port become active. If the variant choice associated with the block evaluates to
false
, all the components connected to this port become
inactive.
By default, this port is untyped. You define the type of this port by connecting it to a conserving port of another block, components in the network, or a Simscape Bus port.
Port_2 — Connection port
untyped conserving port
Conserving connection port. By default, this port is untyped.
You define the type of the port by connecting it to a conserving port of another block, components in the network, or a Simscape Bus port.
Parameters
Connector Type — Type of connector block
Leaf
(default) | Primary
| Nonprimary
Select a connector type based on the components to deactivate.
Leaf
: If you want to deactivate all the components connected to the block, set Connector Type toLeaf
.For example, in this model, the variant condition associated with the Variant Connector block, ConneBlk1, is
A == 1
. The variant condition associated with the Variant Connector block, ConneBlk2, isB == 1
. During simulation, whenA == 1
evaluates totrue
andB == 1
evaluates tofalse
, all the components connected to ConneBlk1 block become active, and all the components connected to ConneBlk2 block become inactive.Primary and Nonprimary
: If you want to restrict the propagation of the variant condition to a set of components, create a Bounded region by using primary and nonprimary connector blocks. To form a bounded region, the primary and nonprimary connector blocks must have the same Connector Tag property.When you set Connector Type to
Primary
orNonprimary
, the connector tag of the block is displayed on the block icon. The connector tag of the primary connector block is displayed with double lines and the connector tag of the nonprimary connector block is displayed with single lines.A primary Variant Connector block and all nonprimary Variant Connector blocks with the same Connector Tag as the primary block constitute a set of related blocks.
You can select a primary or nonprimary Variant Connector block to highlight all related Variant Connector blocks.
The blocks that are highlighted in the model canvas are also highlighted in the miniature map.
To show a related block in an open diagram, pause on the ellipsis that appears after selection. Then, select Related Blocks from the action bar. When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. After you select a related block from the list, window focus goes to the open diagram or new tab that shows the related block.
Connector Tag — Unique identifier of bounded region
A
(default) | valid MATLAB® identifier that starts with a letter, contains no spaces or special
characters and is at most 63 characters long
Specify an identifier in the Connector Tag parameter. The primary and nonprimary connector blocks with the same tag form a Bounded region.
Dependencies
To enable this parameter, set Connector Type to
Primary
or Nonprimary
.
Variant control expression — Variant controls available in global workspace
true
(default) | boolean condition expression
Displays the variant controls available in the global workspace. The variant control
can be a Boolean condition expression containing a regular MATLAB variable or a
object representing a Boolean condition
expression.Simulink.VariantExpression
To edit a variant name, double-click a Variant control expression cell and type in the variant control expression. Click Apply after you edit a variant control name.
When the variant control associated with the block evaluates to
true
, all the components connected to the block become
active.
Programmatic Use
Block Parameter:
VariantControls
|
Type: cell array of character vectors |
Value: Variant control that is associated with the Variant choice |
Default:
'Variant'
|
Condition (read-only) — Condition for Variant controls
no default
This read-only field is based on the condition for the associated Variant control in
the global workspace. Create or change a Variant condition in the
Simulink.VariantExpression
parameter dialog box or in the global
workspace.
For more information, Simulink.VariantExpression
.
Show variant condition on block — Display variant condition on block icon
off (default) | on
Select Show variant condition on block to display the variant condition associated with the block on the block icon.
Open block in Variant Manager — Open Variant Manager window
no default
Click Open block in Variant Manager to open the Variant Manager.
More About
Bounded region
A bounded region is a part of a model located between one Variant Connector block where
Connector type is set to Primary
and any
number of Variant Connector blocks where Connector type is set to
Nonprimary
. All of the blocks in a bounded region must use the
same Connector tag parameter.
For example, this model has two bounded regions. The first region has one primary and
two nonprimary Variant Connector blocks. These blocks are connected to each other by the
connector tag Region1
and the associated variant condition A ==
1
. The second region has one primary and one nonprimary Variant Connector block.
These blocks are connected to each other by the connector tag Region2
and
the associated variant condition B == 1
. During simulation, when
A == 1
evaluates to true
, the components in the
first region become active. When B == 1
evaluates to
false
, the components in the second region become inactive.
When you create a bounded region, ensure that:
Each region has only one primary Variant Connector block. Each primary Variant Connector block is connected to at least one nonprimary Variant Connector block. All Variant Connector blocks must be connected using the port associated with condition information.
All the primary and nonprimary blocks are at the same level of model hierarchy.
Each region has a unique connector tag in a model hierarchy.
The region is bounded and has no external connections.
There are no Variant Connector blocks where the Condition type is set to
Leaf
inside the bounded region.No bounded regions overlap each other.
Variant Condition Propagation From Variant Connector Block to Subsystem Block
The Variant Connector block does not propagate the variant condition across the boundary between the Simscape physical network and the Simulink blocks connected to it. In other words, if a block has both conserving ports and Simulink signal ports, such as a Simulink-PS Converter, a PS-Simulink Converter block, or a Subsystem block, the Variant Connector block stops propagating the variant condition at the boundary of that block. The condition is not propagated to any of its connected blocks.
For example, in this model, as the Subsystem block has both conserving ports and Simulink signal ports, the Variant Connector block does not propagate the variant condition to the Subsystem block.
However, if the Subsystem has only conserving ports, the Variant Connector block propagates the variant condition to the Subsystem block and to the blocks that are connected to the Subsystem block. However, the propagation stops at the PS-Simulink Converter block because it has both conserving ports and Simulink signal ports.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Usage notes and limitations:
The code is generated only for active blocks in the model. Inactive blocks do not participate in code generation.
Version History
Introduced in R2020b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)