which
Locate functions and files
Syntax
Description
which
displays the full path for
item
item
.
If
item
is a MATLAB® function in a MATLAB code file (.m
,.mlx
, or.p
extension), or a saved Simulink® model (.slx
or.mdl
extension), thenwhich
displays the full path for the corresponding file.item
must be on the MATLAB path.If
item
is a method in a loaded Java® class, thenwhich
displays the namespace, class, and method name for that method.If
item
is a workspace variable, thenwhich
displays a message identifyingitem
as a variable.If
item
is an unsaved Simulink model that is loaded in Simulink, thenwhich
displays a message identifyingitem
as a new Simulink model.If
item
is a file name including the extension, and it is in the current working folder or on the MATLAB path, thenwhich
displays the full path ofitem
.
If item
is an overloaded function or method,
then which
item
returns only
the path of the first function or method found.
which ___ -all
displays the paths to all
items on the MATLAB path with the requested name, as well as any files in special
folders that have been implicitly added to the path. Such items include methods
of instantiated classes. For more information about these special folders, see
What Is the MATLAB Search Path. You
can use -all
with the input arguments of any of the previous
syntaxes.
Examples
Input Arguments
Output Arguments
Limitations
When the class is not loaded,
which
only finds methods if they are defined in separate files in an @-folder and are not in any namespaces.
Tips
For more information about how MATLAB uses scope and precedence when calling a function, see Function Precedence Order.
Extended Capabilities
Version History
Introduced before R2006a