matlab中的exist是啥意思
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab中的exist是啥意思相关的知识,希望对你有一定的参考价值。
exist用来判断变量或函数是否存在:
exist Check if variables or functions are defined.exist('A') returns:
0 if A does not exist
1 if A is a variable in the workspace
2 if A is an M-file on MATLAB's search path. It also returns 2 when
A is the full pathname to a file or when A is the name of an
ordinary file on MATLAB's search path
3 if A is a MEX-file on MATLAB's search path
4 if A is a Simulink model or library file on MATLAB's search path
5 if A is a built-in MATLAB function
6 if A is a P-file on MATLAB's search path
7 if A is a directory
8 if A is a class (exist returns 0 for Java classes if you
start MATLAB with the -nojvm option.)
exist('A') or exist('A.EXT') returns 2 if a file named 'A' or 'A.EXT'
and the extension isn't a P or MEX function extension.
exist('A','var') checks only for variables.
exist('A','builtin') checks only for built-in functions.
exist('A','file') checks for files or directories.
exist('A','dir') checks only for directories.
exist('A','class') checks only for classes.
If A specifies a filename, MATLAB attempts to locate the file,
examines the filename extension, and determines the value to
return based on the extension alone. MATLAB does not examine
the contents or internal structure of the file.
When searching for a directory, MATLAB finds directories that are part
of MATLAB's search path. They can be specified by a partial path. It
also finds the current working directory specified by a partial path,
and subdirectories of the current working directory specified by
a relative path.
exist returns 0 if the specified instance isn't found. 参考技术A 检查变量或函数是否被定义 返回0是没有定义 返回1是存在定义在workspace里面 参考技术B >> help exist
EXIST Check if variables or functions are defined.
EXIST('A') returns:
0 if A does not exist
1 if A is a variable in the workspace
2 if A is an M-file on MATLAB's search path. It also returns 2 when
A is the full pathname to a file or when A is the name of an
ordinary file on MATLAB's search path
3 if A is a MEX-file on MATLAB's search path
4 if A is a MDL-file on MATLAB's search path
5 if A is a built-in MATLAB function
6 if A is a P-file on MATLAB's search path
7 if A is a directory
8 if A is a Java class
>> exist('map')
ans =
7
7 if A is a directory
本回答被提问者和网友采纳
以上是关于matlab中的exist是啥意思的主要内容,如果未能解决你的问题,请参考以下文章