Contenido principal

Simulink.VariantManager.findVariantControlVars

Find variables used in variant control expressions

Description

Add-On Required: This feature requires the Variant Manager for Simulink add-on.

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,Name=Value) specifies options using one or more name-value arguments. For example, you can disable the search in referenced models.

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

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: vars = Simulink.VariantManager.findVariantControlVars(model,searchOpt=false);

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

Option to display detailed diagnostic messages during processing, specified as a numeric or logical 0 (false) or 1 (true).

Data Types: logical

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 — Workspace or source defining the variable, which can have one of these values:

    • base workspace

    • data dictionary

    • model workspace

    • mask workspace

    • instance specific constant — The variable is configured as a model argument in a referenced model, and an instance-specific constant value is provided for this variable in a Model block in the parent model.

Version History

Introduced in R2015a