Hauptinhalt

Simulink.VariantConfigurationAnalysis

Analyze variant configurations

    Description

    Add-On Required: This feature requires the Variant Manager for Simulink add-on.

    Use the Simulink.VariantConfigurationAnalysis object to analyze variant configurations for a model by specifying either named variant configurations or variable groups.

    The variant configuration analysis object has functions that can be used to:

    • Compare different variant configurations for a model to understand the model elements used in each.

    • Check if all variant choices have been activated at least once and whether the model is covered completely for simulation and code generation.

    • Verify if the active, implemented model is different between different variant configurations.

    • Find dependent model artifacts such as referenced models and libraries used by a particular variant configuration.

    Creation

    Use either the Simulink.VariantConfigurationAnalysis function (described here) or the Simulink.VariantManager.analyzeModel function to create a VariantConfigurationAnalysis object.

    Description

    varConfigAnalysisObj = Simulink.VariantConfigurationAnalysis(model,Name=Value) analyzes the model specified by model using the options specified by name-value arguments. The function returns a variant configuration analysis object for the model and sets the ModelName and Configurations properties.

    example

    Input Arguments

    expand all

    Name of the model, specified as a character vector or string.

    This argument sets the ModelName property as a character vector.

    Example: "slexVariantReducer"

    Name-Value Arguments

    expand all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: varConfigAnalysisObj = Simulink.VariantConfigurationAnalysis("slexVariantReducer",NamedConfigurations={"config1","config2"})

    Names of variant configurations, specified as a string, a character vector, a cell array of strings, or a cell array of character vectors. Use this argument to perform the analysis by specifying named variant configurations defined for the model. This argument sets the Configurations property as a character vector.

    You can use Variant Manager to create named variant configurations for a model, save them in a variant configuration object of type Simulink.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 the VariantConfigurationObject model parameter contains the name of the corresponding variant configuration object.

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

    Variant control variable names and values, specified as an array of structures. 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 an array of structures with these fields:

    • Name — Name of variable group, specified as a character vector.

    • VariantControls — Variant control variable names and their values, specified as a cell array of character vectors.

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

    Note

    Specifying both NamedConfigurations and VariableGroups is not supported.

    Properties

    expand all

    This property is read-only after object creation.

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

    This property is read-only after object creation.

    Names of variant configurations or variable groups to be analyzed, represented as a cell array of character vectors.

    Example: {'V1W1','V1W2'}

    Object Functions

    getActiveBlocksList of active blocks in a named variant configuration
    getAlwaysActiveBlocksList of blocks that are always active across named variant configurations
    getBlockDifferencesList of blocks that differ in their active choice between multiple named variant configurations
    getDependentLibrariesList of libraries used in a named variant configuration
    getDependentModelsList of dependent models used in a named variant configuration
    getNeverActiveBlocksList of blocks that are inactive in named variant configurations
    getVariantConditionVariant condition on a block in a named variant configuration
    showUIShow variant configuration analysis report for a model
    hideUIHide variant configuration analysis report for a model

    Examples

    collapse all

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

    Open the model slexVariantReducer.

    open_system("slexVariantReducer");

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

    Analyze the model using the named configurations.

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

    Alternatively, specify variable groups for analysis.

    The slexVariantReducer model contains two variant control variables V and W.

    Analyze the model using two variable groups named as V1W1 and V2W2.

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

    Limitations

    Variant Analyzer does not support models that contain variant blocks that use variant control variables defined in the mask or model workspace.

    Version History

    Introduced in R2019a