which
Locate functions and files
Syntax
Description
which displays the full path for
itemitem.
If
itemis a MATLAB® function in a MATLAB code file (.m,.mlx, or.pextension), or a saved Simulink® model (.slxor.mdlextension), thenwhichdisplays the full path for the corresponding file.itemmust be on the MATLAB path.If
itemis a method in a loaded Java® class, thenwhichdisplays the namespace, class, and method name for that method.If
itemis a workspace variable, thenwhichdisplays a message identifyingitemas a variable.If
itemis an unsaved Simulink model that is loaded in Simulink, thenwhichdisplays a message identifyingitemas a new Simulink model.If
itemis a file name including the extension, and it is in the current working folder or on the MATLAB path, thenwhichdisplays 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,
whichonly 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.
whichmatches case-sensitively if able. If there is no case-sensitive match, thenwhichmatches case-insensitively.whichmatchesitemcase-sensitively if able. If there is no exact match, thenwhichattempts matchitemcase-insensitively. Namespace folders and their contents are always matched case-sensitively.
Extended Capabilities
Version History
Introduced before R2006a