Manage Variant Parameters Using Variant Manager - MATLAB & Simulink (original) (raw)
Variant parameter objects enable you to vary the values of block parameters in a SimulinkĀ® model conditionally. You create a variant parameter as a Simulink.VariantVariable object. For an overview of variant parameters, seeUse Variant Parameters to Reuse Block Parameters with Different Values.
Once you set up variant parameters for your model, you can view and manage them by using Variant Manager for Simulink. Variant Manager is a tool that allows centralized management of variations implemented using variant elements such as variant blocks and variant parameters across the model hierarchy. You can install the Variant Manager for Simulink support package from the Add-On Explorer. To open Variant Manager, on theModeling tab in the Simulink toolstrip, open the Design section and clickVariant Manager. For more information, see Variant Manager for Simulink.
View and Edit Variant Parameters in Workspaces Used by Model
The model hierarchy table in Variant Manager presents different views of the model hierarchy. Use the Variant Parameters tab to see all the variant parameters defined in the workspaces associated with the model. The default view shows all variant parameters, even if they are not used in the model hierarchy. In the default view, in the View by section, theChoice option is selected. This setting lists the choices of the variant parameters, one per row. To edit a variant parameter, right-click the row and select Edit Simulink.VariantVariable from the context menu.
View Variant Parameters Used by Model Hierarchy for a Variant Configuration
To view only the variant parameters used by the model hierarchy for a configuration:
- Click Update Model in the Variant Manager toolstrip to obtain model compilation information in Variant Manager. Once compilation information is available, Variant Manager identifies the variant parameters used by the model hierarchy. Parameters that are unused by the model hierarchy for a configuration appear in italics.
- In the Variant Parameters tab, from theShow list, select
Used by configuration
to view only the variant parameters used by the model hierarchy.
Activate and Manage Variant Parameters
A variant configuration contains a set of variant control variables and their values, which you can use to enable a specific variant path in the model hierarchy. You can validate these configurations, save them to a file, and simulate the model using a desired configuration. For more information, see Variant Configurations.
To set up variant configurations for a model with variant parameters:
- Open Variant Manager. Add a new variant configuration for the model. Import control variables from workspaces used by the model and set correct values for them for the configuration.
- Open the Variant Parameters tab. Click Update Model in the Variant Manager toolstrip to obtain model compilation information. This operation helps Variant Manager to identify the variant parameters used by the model hierarchy. Variant Manager then considers only these parameters for subsequent activation and import variant control variable operations.
- Activate the configuration to validate it and to see the results. Variant Manager highlights active choices in the model hierarchy table. For rows with errors, point to them to display a tooltip that shows additional information related to the activation status.
- To optionally see which variant parameter choices make use of a particular control variable, right-click the variable in the control variables table and select Show usage or Hide usage.
- Save your configurations in a variant configuration object and associate it with the model for later use.
For more information, see Create and Activate Variant Configurations and Save and Reuse Variant Configurations Using Variant Configuration Data Object.
View Variant Parameters Grouped by Variant Parameter Bank
A variant parameter bank, which is an object of typeSimulink.VariantBank
, groups variant parameters with the same variant conditions into a structure in the generated code to improve the efficiency and readability of the code. For more information, see Group Variant Parameter Values and Conditionally Switch Active Value Sets in Generated Code (Embedded Coder).
In the Variant Parameters tab, in the View by section, select Bank to switch to a view in which the parameters are grouped based on the variant parameter bank they belong to. The view shows parameters that are not part of any variant bank in a separate section and groups such variant parameters by variant conditions.
This image of the Bank view shows a variant bankParamGrp
that groups two parameters, K1
and K2
. The view groups parameters G1
andG2
that share the same variant conditions and are not part of a variant parameter bank separately.
Create Variant Banks for Variant Parameters from Variant Manager
From the Bank view in the Variant Parameters tab, you can either create a new variant bank for the variant parameters or add them to an existing variant bank. To associate a parameter or a group of parameters with a variant bank:
- In the Variant Parameters without a variant bank section of the table, on the header row of the required group, click the Create
Simulink.VariantBank
button. Alternatively, right-click the row and select Create Simulink.VariantBank from the context menu.
- The Associate with
Simulink.VariantBank
dialog box appears. Variant Manager suggests a default name for theSimulink.VariantBank
object. Modify the name or select an existing variant bank object from theName list. Select the data source in which to create the object from the Source list.
Click OK.
This image shows the creation of a new variant parameter bank to group the variant parametersG1
andG2
. The name of theSimulink.VariantBank
object is set toVariantBankWGroup
. - The
Simulink.VariantBank
dialog box appears. Enter values for the Name and Description properties of the variant bank object. This is the name and description of the structure that represents the variant parameter bank in the code generated using Embedded CoderĀ®.
This image shows the bankVariantBankWGroup
with the parametersG1
andG2
.
See Also
Simulink.VariantVariable | Simulink.VariantBank