%SIMULINK.FINDVARS returns information about workspace variables used or not
%used by a context. A context may comprise blocks and/or models.
% 
%    VARS = Simulink.findVars(CONTEXT) returns one or more 
%    Simulink.VariableUsage objects describing workspace variables referenced
%    by a block or model CONTEXT.
%
%    VARS = Simulink.findVars(CONTEXT, C1, CV1, C2, CV2, ...) uses
%    constraint/value pairs such as C1 and CV1 to constrain the search criteria.
%
%    VARS = Simulink.findVars(CONTEXT, C1, CV1, ..., P1, PV1, ...) uses 
%    property/value pairs such as P1 and PV1 to filter the return values.
% 
%    VARS = Simulink.findVars(CONTEXT, VARS_IN, ...) limits the results to the
%    variables specified in VARS_IN.
%
%    Optional input constraints (default values in parentheses):
%
%      - 'SearchMethod' : ('compiled')|'cached'
%
%          'compiled' - Compile the parent model for each context involved 
%          in the search. Data returned from this search is guaranteed to 
%          be both accurate and complete.
%
%          'cached' - Do not perform a search, but simply return any values 
%          cached during the last compile (update-diagram) of the model 
%          containing CONTEXT. 
%
%      - 'SearchReferencedModels' : ('off')|'on'
%      
%          If on, enable search in referenced models.
%
%      - 'FindUsedVars' : (true)|false
%          
%          true - Find the variables used by the given block or model CONTEXT.
%
%          false - Find the variables that are defined in the model and
%          mask workspaces of the given CONTEXT as well as in the base 
%          workspace, but not used by the CONTEXT. In this mode, the CONTEXT
%          can only be models that are open.
%
%      - 'IncludeEnumTypes' : ('off')|'on'
%          
%          If on, find the enumerated types that are used explicitly in CONTEXT
%          as well as types that define variables that are used in CONTEXT.
%
%      - 'Name' : string or character vector
%       
%          Name of a variable or enumerated data type to search for.
%
%      - 'Regexp' : ('off')|'on'
%          
%          If on, use regular expression pattern matching for when filtering 
%          results for string properties only. 
%      
%      - 'SourceType' : string or character vector
%
%          Workspace or type of source defining the variables or enumerated types.
%          Valid source types for variables are:
%            - 'base workspace'
%            - 'model workspace'
%            - 'mask workspace'
%            - 'data dictionary'
%
%          To search enumerated data types (by specifying 'IncludeEnumTypes' as 'on'),
%          use one of the following source types:
%            - 'MATLAB file'
%            - 'dynamic class'
%            - 'data dictionary'
%
%    Examples:
%
%       % Find all workspace variables used by mymodel
%       vars = Simulink.findVars('mymodel');
%
%       % Find all uses of base workspace variable 'k' by mymodel
%       var = Simulink.findVars('mymodel', ...
%                               'SourceType', 'base', ...
%                               'Name', 'k');
%
%       % Find all uses of variables of a particular pattern by mymodel
%       vars = Simulink.findVars('mymodel', ...
%                                'Regexp', 'on', ...
%                                'Name', '^trans');
%
%       % Find all uses of specific workspace variables by mymodel
%       var_list = who('a*');
%       var_objs = Simulink.VariableUsage(var_list, 'base workspace');
%       vars = Simulink.findVars('mymodel', var_objs);
%
%       % Find all base workspace variables that are not used by mymodel
%       unused_vars = Simulink.findVars('mymodel', ...
%                                       'FindUsedVars', false, ...
%                                       'SourceType', 'base');
%
%    See also Simulink.VariableUsage, find_system

 
%   Copyright 2009-2023 The MathWorks, Inc.

