關於部落格
  • 122904

    累積人氣

  • 31

    今日人氣

    0

    追蹤人氣

EXIST 函數


回傳值:

0 - A 不存在
1 - A 是變數
2 - A 是 M-file
3 - A 是 MEX-file
4 - A 是 MDL-file (Matlab only)
5 - A 是 built-in 函數
6 - A 是 P-file (Matlab only)
7 - A 是資料夾
8 - A 是 Java 類別 (Matlab only)

應用:

利用M檔案撰寫函數時可以用來當作防呆機制, 當使用者沒有輸入變數時
可以自行指定預設值或是要求使用者輸入

說明文件原文:

 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('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 Java classes.
 
    EXIST returns 0 if the specified instance isn't found.
 
    See also DIR, WHAT, ISEMPTY.


相簿設定
標籤設定
相簿狀態