I have two implementations of a function one as an m file and one as a mex file. They live in the same directory, which is on the top of the Matlab path. When I call the function from my home directory, I use the m file, but if I cd to the directory where both the m and mex files are located I end up using the mex file.
For example:
>> cd ~>> which lookup/usr/local/MATLAB/R2011b/toolbox/compecon/CEtools/lookup.m>> cd /usr/local/MATLAB/R2011b/toolbox/compecon/CEtools>> which lookup/usr/local/MATLAB/R2011b/toolbox/compecon/CEtools/lookup.mexa64
Notice that I get the m file in the first case and the mex file in the second. Why this difference? I would always like to use the mex file.
Best Answer