变体参数
使用 Simulink® 中的变体参数,您可以在单个模型中表示一个系统的各种不同值。您可以根据要仿真的变体对不同值集进行分组。您可以根据变体控制项激活每个值集。您可以在任何 Simulink 模块中包含变体参数。有关详细信息,请参阅什么是变体以及何时使用变体。
您可以使用 Variant Manager for Simulink 来管理模型中的变体参数。
为变体参数生成的代码可以包含一个系统的所有可能值。您可以在代码编译前或在模型启动时在值之间切换,如Activate Variant During Different Stages of Simulation and Code Generation Workflow中所述。
主题
- Options to Represent Variant Parameters in Generated Code
You can generate the code only for active values or for both active and inactive values of variant parameters in Simulink.
- Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions
This example shows how to generate a C code that contains all the active and inactive values of variant parameters.
- Run Executable for Different Variant Parameter Values Without Recompiling Code
This example shows how to generate an executable that runs for different set of variant parameter values without needing to recompile the code for each set of values.
- Improve Code Readability of Variant Parameters Using Enumerated Types
You can use enumerated types to improve code readability of variant control values in variant parameters.
- Reuse Variant Parameter Values from Handwritten Code Using Simulink.Parameter Variables
This example shows how to use
variables to generate a code that imports variant parameter values from your existing code.Simulink.Parameter
- Group Variant Parameter Values and Conditionally Switch Active Value Sets in Generated Code
Learn how to use variant parameter banks to group variant parameters in generated code.