Main Content

findVariantControlVars

Class: Simulink.VariantManager
Package: Simulink

Find variables used in variant control expressions

Syntax

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

Description

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.

Examples

expand all

Open the model slexVariantManagement.

cd(fullfile(matlabroot,'examples','simulink_variants','main'));
model = 'slexVariantManagement';
open_system(model); 

Create an object of the Simulink.VariantManager class.

varmngr=Simulink.VariantManager;

Find the variant control variables.

vars = varmngr.findVariantControlVars(model)
vars=6×1 struct array with fields:
    Name
    Value
    Exists
    Source
    SourceType

Version History

Introduced in R2015a