MATLAB Function Reference |
Graphical Interface
As an alternative to the which
function, use the Current Directory browser.
Syntax
which fun which classname/fun whichprivate
/fun which classname/private
/fun which fun1in
fun2 which fun(a,b,c,...) which file.ext which fun-all
s = which('fun',...)
Description
which fun
displays the full pathname for the argument fun
. If fun
is a
which
displays the full pathname for the corresponding file
which
displays a message identifying fun
as a variable
which
displays the package, class, and method name for that method
If fun
is an overloaded function or method, then which
fun
returns only the pathname of the first function or method found.
which classname/fun
displays the full pathname for the M-file defining the fun
method in MATLAB class, classname
. For example, which
serial/fopen
displays the path for fopen.m
in the MATLAB class directory, @serial
.
which
limits the search to private functions. For example, private
/fun
which
private/orthog
displays the path for orthog.m
in the /private
subdirectory of toolbox/matlab/elmat
.
which classname/
limits the search to private methods defined by the MATLAB class, private
/fun
classname
. For example, which
dfilt/private/todtf
displays the path for todtf.m
in the private
directory of the dfilt
class.
which fun1
displays the pathname to function in
fun2
fun1
in the context of the M-file fun2
. You can use this form to determine whether a subfunction or private version of fun1
is called from fun2
, rather than a function on the path. For example, which
get in
editpath
tells you which get
function is called by editpath.m
.
During debugging of fun2
, using which
fun1
gives the same result.
which fun(a,b,c,...)
displays the path to the specified function with the given input arguments. For example, which feval(g)
, when g=inline('sin(x)')
, indicates that inline/feval.m
would be invoked. which toLowerCase(s)
, when s=java.lang.String('my Java string')
, indicates that the toLowerCase
method in class java.lang.String
would be invoked.
which file.ext
displays the full pathname of the specified file if that file is in the current working directory or on the MATLAB path. Use exist
to check for the existence of files anywhere else.
which fun
displays the paths to all items on the MATLAB path with the name -all
fun
. You may use the -all
qualifier with any of the above formats of the which
function.
s = which('fun',...)
returns the results of which
in the string s
. For workspace variables, s
is the string 'variable
'. You may specify an output variable in any of the above formats of the which
function.
If -all
is used with this form, the output s
is always a cell array of strings, even if only one string is returned.
Examples
The statement below indicates that pinv
is in the matfun
directory of MATLAB.
To find the fopen
function used on MATLAB serial
class objects
To find the setTitle
method used on objects of the Java Frame
class, the class must first be loaded into MATLAB. The class is loaded when you create an instance of the class:
When you specify an output variable, which
returns a cell array of strings to the variable. You must use the function form of which
, enclosing all arguments in parentheses and single quotes:
s = which('private/stradd','-all'); whos s Name Size Bytes Class s 3x1 562 cell array Grand total is 146 elements using 562 bytes
See Also
dir
, doc
, exist
, lookfor
, mfilename
, path
, type
, what
, who
whatsnew | while |
© 1994-2005 The MathWorks, Inc.