function result=FileExists(filename)
% Checks if a file actually exists
% Returns zero if no such file
% Returns non-zero if file exists

% test for proper filename
if ~isstr(filename)
	error('FileExists: Filename must be a string argument!');
end

% open the file 
fid = fopen(filename,'r');
if fid == (-1)
	result = 0;
else
	result = 1;
	fclose(fid);
end


