if exist('JaccardDistance', 'file')==1
load('JaccardDistance');
else
% Do things
end
The file JaccardDistance is in the same folder where this code is being executed. The problem is that the "else" part is always being executed, which means that it is not recognizing that the file JaccardDistance exists. What am I doing wrong? Thanks in advance.
The file_exists() function checks whether a file or directory exists.
Description. fclose( fileID ) closes an open file. fclose('all') closes all open files.
exist name searchType returns the type of name , restricting results to the specified type, searchType . If name of type searchType does not exist, MATLAB returns 0 . A = exist(___) returns the type of name to A .
On the Home tab, in the File section, click Open , and then select a file to open. You also can double-click the file in the Current Folder browser.
For files you exists will return a 2 not a 1. You should also include the file extension in the check.
if exist('JaccardDistance.m', 'file') == 2
ref matlab forum Or read the manual:
exist name returns the status of name:
0
name does not exist.1
name is a variable in the workspace.2
One of the following is true:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With