Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Locate functions and files

`which item`

`which fun1 in fun2`

`which ___ -all`

`str = which(item)`

`str = which(fun1,'in',fun2)`

`str = which(___,'-all')`

`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 Simulink^{®}model (`.slx`

or`.mdl`

extension), then`which`

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, then`which`

displays the package, class, and method name for that method.If

`item`

is a workspace variable, then`which`

displays a message identifying`item`

as a variable.If

`item`

is a file name including the extension, and it is in the current working folder or on the MATLAB path, then`which`

displays the full path of`item`

.

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.
Such items include methods of instantiated classes. You can use `-all`

with
the input arguments of any of the previous syntaxes.

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 packages.

For more information about how MATLAB uses scope and precedence when calling a function, see Function Precedence Order.

Was this topic helpful?