このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
バリアント パラメーター
Simulink® のバリアント パラメーターを使用すると、システムの値のバリエーションを単一のモデルで表現できます。シミュレートするバリアントに基づいて、さまざまな値のセットをグループ化できます。バリアント制御に応じて、各値セットをアクティブにできます。バリアント パラメーターを任意の Simulink ブロックに組み込むことができます。詳細については、バリアントとは、およびどのような場合にそれを使用するかを参照してください。
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. You can also represent the values of variant parameters as inline variables or as tunable variables in the generated code.
- 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. Simulink 列挙型 improve readability because enumerated types of variant controls values are represented as meaningful names instead of integers in the generated code.
- 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. The values are enclosed in preprocessor conditionals
#if
and#elif
that enables you to compile the code conditionally based on the condition that evaluates totrue
. - 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.
- 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. Importing variant parameter values allows you to reuse the values that your existing code defines. You can then integrate and compile the generated and existing code into a single executable. You can choose to generate a code that imports variant parameter values at the beginning of code compile, simulation-loop, or model startup phases of simulation and code generation workflows based on the activation time you specify. For more information, see Activate Variant During Different Stages of Simulation and Code Generation Workflow.Simulink.Parameter
- Generate Code for Instance-Specific Variation of Variant Parameter Values in Model Reference Hierarchy
Configure instance-specific values for variant parameters in a referenced model.
- Configure Code Generation for Variant Parameters in Model Workspace Using Code Mappings Editor
Learn how to use the Code Mappings editor to configure the code generation attributes for Simulink.VariantVariable and Simulink.VariantControl objects defined in the model workspace of a model.