How to check the existence of the specified file in MatLab? - exist -- MatLab

 How to check the existence of the specified file in MatLab? - exist -- MatLab


How to check the existence of the specified file in MatLab? 
[Ans]
exist

[syntax]



<result>=exist(<name>);
<result>=exist(<name>,<searchType>);

[description]
<result>=exist(<name>);
exist name returns the type of name as a number.

  • 0 — name does not exist or cannot be found for other reasons. For example, if name 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 .m.mlx, or .mlapp, or name is the name of a file with a non-registered file extension (.mat.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 option.)


<result>=exist(<name>,<searchType>);
It will return true when <name> is kind of  <searchType>.
Otherwise, return false.


more details on:

Comments

Popular posts from this blog

How to join a file path with multiple char vector or string in MatLab? - fullfile -- MatLab