MATLAB Function Reference
  Go to function:
    Search    Help Desk 
which    Examples   See Also

Locate functions and files

Syntax

Description

which fun displays the full pathname of the specified function. The function can be an M-file, MEX-file, workspace variable, built-in function, or SIMULINK model. The latter three display a message indicating that they are variable, built in to MATLAB, or are part of SIMULINK. Use which private/fun or which class/fun or which class/private/fun to further qualify the function name for private functions, methods, and private methods (for the class named class).

which fun -all displays the paths to all functions with the name fun. The first one in the list is the one normally returned by which. The others are either shadowed or can be executed in special circumstances. The -all flag can be used with all forms of which.

which file.ext displays the full pathname of the specified file.

which fun1 in fun2 displays the pathname to function fun1 in the context of the M-file fun2. While debugging fun2, which fun1 does the same thing. You can use this to determine if a local or private version of a function is being called instead of a function on the path.

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 is invoked.

s = which(...) returns the results of which in the string s instead of printing it to the screen. s will be the string built-in or variable for built-in functions or variables in the workspace. You must use the functional form of which when there is an output argument.

Examples

For example,

reveals that inv is a built-in function, and

indicates that pinv is in the matfun directory of the MATLAB Toolbox.

The statement

probably says

because there is no file jacobian.m on MATLAB's search path. Contrast this with lookfor jacobian, which takes longer to run, but finds several matches to the keyword jacobian in its search through all the help entries. (If
jacobian.m does exist in the current directory, or in some private directory that has been added to MATLAB's search path, which jacobian finds it.)

See Also

dir, exist, help, lookfor, path, what, who



[ Previous | Help Desk | Next ]