| MATLAB Function Reference | Search  Help Desk |
| exist | Examples See Also |
Check if a variable or file exists
Syntax
a = exist('item')
ident = exist('item','kind')
Description
a = exist('item')
returns the status of the variable or file item:exist('item')
returns 2 if item is on the MATLAB search path. item may be a MATLABPATH relative partial pathname. item may be item.ext, but the filename extension (ext) cannot be mdl, p, or mex.
ident = exist('item','kind')
returns logical true (1) if an item of the specified kind is found, and returns 0 otherwise. kind may be: |
Checks only for variables. |
|
Checks only for built-in functions. |
|
Checks only for files. |
|
Checks only for directories. |
Examples
exist can check whether a MATLAB function is built-in or a file:
ident = exist('plot')
ident =
5
plot is a built-in function.
See Also
dir, help, lookfor, partialpath, what, which, who