Main Content


Class: Simulink.VariantManager
Package: Simulink

Find variables used in variant control expressions



This method requires Variant Manager for Simulink®.


vars = Simulink.VariantManager.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 = Simulink.VariantManager.findVariantControlVars(model,'SearchReferencedModels','off') disables the search in referenced models. By default, this search is enabled across the model hierarchy.

Input Arguments

expand all

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

Data Types: char | string

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

Output Arguments

expand all

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

  • Name — Name of the variable used in the variant control expression.

  • Value — Value of the variable. This field is 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, this 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';

Find the variant control variables.

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

Version History

Introduced in R2015a