Main Content

Simulink.VariantManager.analyzeModel

Analyze variant model for specified variant configurations

Since R2026a

    Description

    A variant configuration defines a specific combination of variant choices within a variant model, allowing you to activate a particular variant throughout the model hierarchy. The Simulink.VariantManager.analyzeModel function enables you to analyze multiple variant configurations for a model, helping you to identify the common and differing model elements across configurations.

    You can use this function to analyze named variant configurations that have been created for a model, or to perform an analysis after specifying values for variant control variables. The function also generates a variant analysis report that allows you to:

    • Determine whether all variant choices are activated at least once and whether the model is covered completely for simulation and code generation.

    • Determine whether the active, implemented model differs between variant configurations.

    • Identify dependent model artifacts, such as referenced models and libraries, that are used by specific variant configurations.

    To access this functionality from Variant Manager for Simulink®, use the Variant Analyzer tool. For an overview, see Analyze Variant Configurations in Models Containing Variant Blocks.

    Simulink.VariantManager.analyzeModel(modelName,Name=Value) analyzes the variant model modelName using the options specified by name-value arguments, and then opens the variant analysis report. You can use the options to specify which configurations to analyze, and whether to display or hide the report after the analysis.

    For more information on the variant analysis report, see Explore Variant Analysis Report.

    example

    varConfigAnalysisObj = Simulink.VariantManager.analyzeModel(modelName,Name=Value)opens the variant analysis report and returns a Simulink.VariantConfigurationAnalysis object after the analysis. You can call functions of this object to perform further operations on the analysis results.

    example

    Examples

    collapse all

    Analyze variant configurations for the slexVariantConfigurationAnalysis model.

    Open the model. The model contains predefined variant configurations saved in a Simulink.VariantConfigurationData object named sensor_configs.

    modelName = "slexVariantConfigurationAnalysis";
    open_system(modelName);

    Analyze the model for the predefined configurations VendorACtrlLinear and VendorACtrlNonLinear and open the variant analysis report.

    Simulink.VariantManager.analyzeModel(modelName, ...
        NamedConfigurations={"VendorACtrlLinear","VendorACtrlNonLinear"});

    Get a Simulink.VariantConfigurationAnalysis object that you can use to retrieve useful information from the analysis results. To do this, use an output argument with the function call to store the object.

    varConfigAnalysisObj = Simulink.VariantManager.analyzeModel(modelName, ...
        NamedConfigurations={"VendorACtrlLinear","VendorACtrlNonLinear"})
    varConfigAnalysisObj = 
      VariantConfigurationAnalysis with properties:
    
             ModelName: 'slexVariantConfigurationAnalysis'
        Configurations: {'VendorACtrlLinear'  'VendorACtrlNonLinear'}
    
    

    Find the active blocks in the configuration VendorACtrlLinear from the analysis results saved in varConfigAnalysisObj.

    activeblocks = getActiveBlocks(varConfigAnalysisObj,"VendorACtrlLinear");

    Get the list of dependent libraries for the configuration VendorACtrlLinear.

    dependentLibraries = getDependentLibraries(varConfigAnalysisObj,"VendorACtrlLinear");

    Analyze the model without opening the variant analysis report.

    varConfigAnalysisObj = Simulink.VariantManager.analyzeModel(modelName, ...
        NamedConfigurations={"VendorACtrlLinear","VendorACtrlNonLinear"},ShowUI=false);

    Analyze the model for a configuration by specifying a variable group. To do this, specify the values for the variant control variables that define the configuration as a structure.

    Simulink.VariantManager.analyzeModel(modelName, ...
        VariableGroups=[struct('Name','VendorBNonLinVarGrp','VariantControls',{{'CONTROLLER',CONTROLLERS.NONLINEAR, ...
        'EXTERNAL_SENSOR',1,'ORDER',1,'SATURATE',1,'VENDOR',VENDORS.B}})])

    Input Arguments

    collapse all

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

    Example: "slexVariantConfigurationAnalysis"

    Data Types: char | string

    Name-Value Arguments

    collapse 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.VariantManager.analyzeModel("slexVariantConfigurationAnalysis", NamedConfigurations={"VendorACtrlLinear","VendorACtrlNonLinear"})

    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.

    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={"VendorACtrlLinear","VendorACtrlNonLinear"}

    Data Types: char | string | cell

    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}})]

    Option to show the variant analysis report, specified as a numeric or logical 1 (true) or 0 (false).

    Data Types: logical

    Option to display detailed diagnostic messages during processing, specified as a numeric or logical 0 (false) or 1 (true).

    Data Types: logical

    Output Arguments

    collapse all

    Variant configuration analysis data for the specified variant configurations, returned as a Simulink.VariantConfigurationAnalysis object.

    Version History

    Introduced in R2026a