Main Content

Simulink.VariantConfigurationAnalysis class

Package:金宝app

Analyze variant configurations programmatically

Description

Use theSimulink.VariantConfigurationAnalysisclass to analyze variant configurations for a model by specifying either named variant configurations or variable groups. The class returns a variant configuration analysis object and has methods that can be used to:

  • Get a list of active blocks for variant configuration.

  • Find blocks that are active across all variant configurations.

  • Find blocks that are inactive in all variant configurations.

  • Get a list of blocks that differ in active choice between variant configurations.

  • Get a list of active models for variant configuration.

  • Get a list of libraries that are used in variant configuration.

  • View variant configuration analysis in user interface.

  • Hide the variant configuration analysis report.

  • View variant conditions for blocks in a given variant configuration.

Creation

varConfigObj= Simulink.VariantConfigurationAnalysis(model,Name,Value)returns a variant configuration analysis object for the model specified bymodeland sets theModelNameandConfigurationsproperties.

Input Arguments

expand all

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

Example:'NamedConfigurations', {'config1', 'config2'}

Names of variant configurations, specified as a string or a cell array of strings. Use this argument to perform the analysis by specifying named variant configurations defined for the model.

You can use Variant Manager to create named variant configurations for a model, save them in a variant configuration object of typeSimulink.VariantConfigurationData, and associate this object with the model. You can specify one or more configuration names defined in this variant configuration object for the analysis.

Note

If the model is associated with a variant configuration object, then theVariantConfigurationObjectmodel parameter contains the name of the corresponding variant configuration object.

Example:NamedConfigurations={'config1', 'config2'}

Variant control variable names and values, specified as a struct array. Use this argument to perform the analysis by specifying values for the variant control variables used by the model.

You can specify multiple variable groups that represent the different variant configurations to be analyzed. In each variable group, you must specify the variant control variables and their values that must be used for the analysis.

To define the variable groups, provide a struct array with these fields:

  • Name— Name of variable group

  • VariantControls— Cell array with variant control variable names and their values

Example:'VariableGroups',[struct('Name', 'V1W1',... 'VariantControls', {{'V',1,'W',1}}),struct('Name', 'V1W2',... 'VariantControls', {{'V',1,'W',2}})]

Note

Specifying bothNamedConfigurationsandVariableGroupsis not supported.

Properties

expand all

Name of model to be analyzed, specified as a character vector.

Example:'slexVariantReducer'

Attributes:

GetAccess
public
SetAccess
private

Data Types:character vector

Names of variant configurations or variable groups to be analyzed, specified as a cell array of strings.

Example:{'config1', 'config2'}

Attributes:

GetAccess
public
SetAccess
private

Data Types:character vector

Methods

expand all

Examples

collapse all

Create a variant configuration analysis object by specifying either named variant configurations or variable groups.

Open the modelslexVariantReducer.

open_system('slexVariantReducer');

The model has two named variant configurations,config1andconfig2.The named configurations are saved in a variant configuration object,slexVariantReducer_config, associated with the model.

Analyze the model using the named configurations.

VarConfigObjnc = Simulink.VariantConfigurationAnalysis('slexVariantReducer',...'NamedConfigurations',{'config1','config2'})
VarConfigObjnc = VariantConfigurationAnalysis with properties: ModelName: 'slexVariantReducer' Configurations: {'config1' 'config2'}

Next, specify variable groups for analysis.

TheslexVariantReducermodel contains two variant control variablesVandW.

Analyze the model using two variable groups,V1W1andV2W2:

VarConfigObjvg = Simulink.VariantConfigurationAnalysis(...'slexVariantReducer',...'VariableGroups',[struct('Name','V1W1','VariantControls', {{'V',1,'W',1}}),...struct('Name','V1W2','VariantControls',{{'V',1,'W',2}})])
VarConfigObjvg = VariantConfigurationAnalysis with properties: ModelName: 'slexVariantReducer' Configurations: {'V1W1' 'V1W2'}

版本历史

Introduced in R2019a