Main Content

Simulink.VariantManager.findVariantControlVars

Class: Simulink.VariantManager
Package: Simulink

Find variables used in variant control expressions

Description

Note

This method requires Variant Manager for Simulink®.

example

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(mdl,'SearchReferencedModels',searchOpt) specifies whether to 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 base workspace or data dictionary used by the model.

  • Exists — Logical value that indicates if the variable is defined in the base workspace or data dictionary used by the model. If the variable is defined, 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.

Examples

expand 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=6×1 struct array with fields:
    Name
    Value
    Exists
    Source
    SourceType

Version History

Introduced in R2015a