Check existence of variable, script, function, folder, or class
exist
返回类型name
name
as a number. This list describes the type associated with each value:
0 —name
does not exist or cannot be found for other reasons. For example, ifname
exists in a restricted folder to which MATLAB®does not have access,exist
returns 0.
1-name
is a variable in the workspace.
2 —name
is a file with extension上午
,.mlx文件
, or上午lapp
, orname
是具有未注册文件扩展名的文件的名称(上午at
,.fig
,.txt文件
).
3 —name
is a MEX-file on your MATLAB search path.
4 —name
is a loaded Simulink®model or a Simulink model or library file on your MATLAB search path.
5 —name
is a built-in MATLAB function. This does not include classes.
6 —name
is a P-code file on your MATLAB search path.
7 —name
is a folder.
8 —name
is a class. (exist
returns 0 for Java classes if you start MATLAB with the-nojvm
选项。)
MATLAB searches starting at the top of the search path, and moving down until a result is found or the last folder on the path is reached. If more than onename
exists in a folder, MATLAB displays the first instance ofname
, according to theFunction Precedence Order. Folders are an exception to the function precedence rules. They have precedence over all types except for variables and built-in functions.
For example, ifname
matches both a file with a上午
extension and a P-code file, thenexist
returns 6, identifying it as a P-code file. Ifname
matches both a variable and a P-code file, exists returns 1, identifying it as a variable. Ifname
matches both a folder and a MATLAB function,exist
returns7
, identifying it as a folder.
exist
返回类型name
searchType
name
,将结果限制为指定类型,searchType
. Ifname
of typesearchType
does not exist, MATLAB returns0
.