Main Content

Simulink.VariantManager.findVariantControlVars

Find variables used in variant control expressions

Description

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.VariantExpression object, then the variables are retrieved from the variant condition within the object.

example

vars = Simulink.VariantManager.findVariantControlVars(model,'SearchReferencedModels',searchOpt) specifies whether to search in referenced models. By default, this search is enabled across the model hierarchy.

Note

To use this function, you must install the Variant Manager for Simulink® support package.

Examples

collapse all

This example shows how to find the variant control variables used in a model.

Open the model slexVariantManagement.

model = 'slexVariantManagement';
open_system(model); 

Find the variant control variables.

vars = Simulink.VariantManager.findVariantControlVars(model)
vars=7×1 struct array with fields:
    Name
    Value
    Exists
    Source
    SourceType

Input Arguments

collapse all

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

Example: "slexVariantManagement"

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

collapse all

Variant control variables for the 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 value is 0 if the variable is not defined in the base workspace or data dictionary used by the model.

  • Exists — Logical value that indicates if the variable is defined in the data sources used by the model. If the variable is defined, this value is true. Otherwise, this value is false.

  • Source — Value is name of the data source where the variable is defined.

  • SourceType — Value indicates the type of data source where the variable is defined.

Version History

Introduced in R2015a