Main Content


Class: Simulink.VariantManager
Package: Simulink

Find variables used in variant control expressions


vars = findVariantControlVars(Model)
vars = findVariantControlVars(Model,'SearchReferencedModels','on')


vars = findVariantControlVars(Model) returns the variant control variables used by variant blocks and variant parameters in the model, Model. If the variant control is a Simulink.Variant object, then the variables are retrieved from the variant condition within the object.

vars = findVariantControlVars(Model,'SearchReferencedModels','on') enables the search in referenced models.

Input Arguments

expand all

Model name for which variant control variables must be found, specified as character vector.

Data Types: char

Option to search in referenced models within the given model, specified as 'on' or 'off'. By default, search is enabled for referenced models.

Data Types: char

Output Arguments

expand all

Variant control variables for model, returned as an N-by-1 struct with fields:

Name: Name of the variable used in the variant control expression.

Value: Value of the variable. This field will be 0 if the variable is not defined in the global workspace of the model.

Exists: Logical value that indicates if the variable is defined in the global workspace of the model. If the variable is defined in the global workspace, value is true; otherwise false.

Source: Value is either base workspace or the name of the data dictionary where the variable is stored.

SourceType: Value is either base workspace or data dictionary depending on where the variable is stored.


expand all

Open the model slexVariantManagement.

model = 'slexVariantManagement';

Create an object of the Simulink.VariantManager class.


Find the variant control variables.

vars = varmngr.findVariantControlVars(model)
vars=6×1 struct array with fields:

Version History

Introduced in R2015a