| MATLAB Function Reference | Search  Help Desk |
| exist | Examples See Also |
Check if a variable or file exists
a = exist('item')
ident = exist('item',kind)
a = exist('item')
returns the status of the variable or file item: exist('item') or exist('item.ext')returns 2 if item is on the MATLAB search path but the filename extension (ext) is not mdl, p, or mex. item may be a MATLABPATH relative partial pathname.
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. |
exist can check whether a MATLAB function is built-in or a file:
ident = exist('plot')
ident =
5
plot is a built-in function.
dir Directory listing
help Online help for MATLAB functions and M-files
lookfor Keyword search through all help entries
what Directory listing of M-files, MAT-files, and MEX-files
which Locate functions and files
who List directory of variables in memory
See also partialpath.