1function res = existfile(fileName) 2%EXISTFILE Check for file existence. 3% RES = EXISTFILE(FILENAME) returns true if the file FILENAME is existing 4% on the current path and false otherwise. It works similar to 5% EXIST(FILENAME, 'file'), except that it does not find files on the 6% Matlab path! 7% 8% The function is realized as a mex function (existfile.c). To compile the mex-function, move to the directory where 9% file existfile.c is located and type 10% 11% mex existfile.c 12% 13% If this is the first time you run function MEX on your system, you 14% might have to select a compiler by typing 15% 16% mex -setup 17% 18% If the mex-file (e.g. existfile.mexw32 or existfile.mexglx) is not 19% existing, a (very slow) MATLAB realization is called instead. 20% 21% Markus Buehren 22% Last modified 13.11.2007 23% 24% See also EXIST. 25 26%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27persistent warnmex 28if isempty(warnmex) 29 disp(sprintf('This is the m-file %s.m, not the mex-file! Type "mex existfile.c" to compile.', mfilename)); 30 warnmex = 1; 31end 32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 34% check input arguments 35res = exist(fileName, 'file') ~= 0; 36