Analyze relationship between variables and blocks in models
[
finds
and returns variables that are used in the blocks and models specified
by variables
] = Simulink.findVars(context
)context
, including subsystems and referenced
models. The function returns an empty vector if context
does
not use any variables.
[
finds
only the variables or enumerated types that are specified by variables
] = Simulink.findVars(context
,variablefilter
)variablefilter
.
For example, use this syntax to determine where a variable is used
in a model.
[
finds
variables with additional options specified by one or more variables
] = Simulink.findVars(___,Name,Value
)Name,Value
pair
arguments. For example, you can search for unused variables. You can
also search for enumerated data types that are used in context
,
in addition to variables.
Simulink.findVars
does not work with these
constructs:
MATLAB® code in scripts and initialization and callback functions
Libraries and blocks in libraries
Variables in MATLAB Function blocks, except for input arguments
However, Simulink.findVars
can find enumerated
types anywhere they are used in MATLAB Function blocks.
Calls directly to MATLAB from the Stateflow® action language
S-functions that use data type variables registered
using ssRegisterDataType
To make the variables searchable, use ssRegisterTypeFromNamedObject
instead.
Variables referenced by machine-parented data in Stateflow.
Variables inside a string.
Field in a struct
.
Simulink.findVars
discovers variable usage in inactive subsystem variants
only if you set the Variant activation time parameter to
code compile
in the Variant Subsystem
block dialog box. If you do not select this check box, the function does not discover
variable usage in inactive variants.