Contents Previous Next Subchapters

Determine if an Identifier is Defined (Mlmode)
Syntax exist(id)
See Also path , exists , defined

Determines the meaning of the identifier specified by id in the current environment where id is a string . The return value is a integer with the following meaning:
Value Meaning
0 has type novalue or is not defined and there is no corresponding automatic include file
1 variable that does not have type novalue
2 is a defined function or corresponds to an automatic include file
5 intrinsic function

This function is intended to provide as much compatibility with the MATLAB® version as possible. The type novalue is a special case because variables that are defined in O-Matrix, but not yet assigned a value have this type in O-Matrix. The MATLAB® version of exist returns zero for such variables.

Returns true or false depending on if the identifier specified by the string id is of the specified kind where kind is equal to 'var', 'builtin', or 'file'.

Suppose the file temp.m is in the current directory and contains the text
     function y = temp(x)
     y = exist('x');
If in Mlmode you enter
O-Matrix will respond
On the other hand if you continue by entering
O-Matrix will respond
Note that the nargin function is the suggested way to determine if an argument is present in the call to a function.