| Contents | Index |
[VarsOut] = Simulink.findVars
(context)
[VarsOut] = Simulink.findVars
(context, Options, VarProps)
[VarsOut] = Simulink.findVars
(context, VarsIn, Options,
VarProps)
[VarsOut] = Simulink.findVars (context) returns one or more Simulink.WorkspaceVar objects. Each object describes a workspace variable used by context, which is the name of a model, the name of a block (possibly masked) specified as modelname/blockname, or a cell array of model and/or block names. The search for variables includes all subsystems and referenced models in context. The returned VarsOut includes an object for every variable referenced directly or indirectly by context, except as noted in the Limitations below.
[VarsOut] = Simulink.findVars (context, Options, VarProps) searches context as specified by Options and includes in VarsOut only Simulink.WorkspaceVar objects that satisfy the Options and match the specification(s) in VarProps. See Input Arguments for more information.
[VarsOut] = Simulink.findVars (context, VarsIn, Options, VarProps) limits the results to the variables specified in VarsIn, where VarsIn may be a Simulink.WorkspaceVar object or an array of Simulink.WorkspaceVar objects.
context |
The name of a model, the name of a block specified as modelname/blockname, or a cell array containing any number of model names and/or block names. |
Options |
Specifications that control the search for variables. You can omit any or all Options. The possible Options are:
|
VarProps |
One or more fieldname/value pairs used to filter the results. Only Simulink.WorkspaceVar objects in which the field called fieldname has the value value appear in the output argument list VarsOut. A fieldname can be:
Default: Return all Simulink.WorkspaceVar objects, subject to the specifications in Options, that match whatever VarProps specifications are provided. Omitting a VarProps pair effectively wildcards that Simulink.WorkspaceVar field value. |
VarsOut |
A vector containing zero or more Simulink.WorkspaceVar objects. Each element describes a workspace variable that meets the criteria defined by the input arguments. The vector is empty if no variables match the specifications. |
Find all variables that MyModel uses, recompiling first:
[VarsOut]=Simulink.findVars('MyModel')Find all uses of the base workspace variable k by MyModel without recompiling the model:
[VarsOut]=Simulink.findVars('MyModel', 'Name', 'k', 'SearchMethod', 'cached', 'WorkspaceType', 'base')Find in any workspace any uses of a variable whose names match a regular expression:
[VarsOut]=Simulink.findVars('MyModel', 'Regexp', 'on', 'Name', '^trans')Given two models, discover which variables are needed by the first model, the second model, or both models:
model1Vars = Simulink.findVars('model1');
model2Vars = Simulink.findVars('model2');
commonVars = intersect(model1vars, model2Vars);
Locate all variables in the base workspace that are not being used by MyModel:
unusedVars = Simulink.findVars('MyModel', 'FindUsedVars', false, 'WorkspaceType', 'base');Determine if the base workspace variable k is not used by MyModel:
varObj = Simulink.WorkspaceVar('k', 'base workspace');
unusedVar = Simulink.findVars('MyModel', varObj, 'FindUsedVars', false);Find the variables that are used by the Gain1 block in MyModel:
[VarsOut] = Simulink.findVars('MyModel', 'UsedByBlocks', 'MyModel/Gain1');Simulink.findVars does not work with the following constructs:
MATLAB code in scripts, initialization and callback functions, etc.
Libraries and blocks within libraries
MATLAB Function blocks, except for input arguments
Calls directly to MATLAB from the Stateflow action language
S-functions that use data type variables registered
via ssRegisterDataType.
(To make
the variables findable, use ssRegisterTypeFromNamedObject instead.)
Variables of enumerated classes
find_system | intersect | Simulink.WorkspaceVar

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |