When to use Enumerations in Variant control expressions?

1 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
The variant choices you select, determine which components of a Simulink model get activated or deactivated.
You can create a Variant control (e.g: engine ) and associate it with an expression say: "engine == 1", "engine == 2", and "engine == 3". The Variant control expressions get evaluated and decide the active choice of a Variant block.
In a likely scenario, there could be many variant blocks in your model, and typing and changing expressions like "engine == 1" may lead to less readability. To associate your variant controls with more meaningful names, use Enumerations.
Exploring  "Enumerations" in expression mode can help you with self-explanatory
.
Instead of " engine == 1", you can have "engine == Engine.TURBO"
To get started, please consider exploring some examples demonstrating Simulink Variant capabilities.
Using Enumeration in Variant control expression has advantage over using label mode, as they can be used for Variant parameters too. If you want to learn more on how to create parameters that have multiple values, please refer to the documentation:
Variant Parameters require association with a variant condition expression and enumerations come in handy to use self-explanatory names for Variant controls. Please refer to this
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Variant Hierarchical Components 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by