Matlab tries to use mex files not on search path
1 view (last 30 days)
Show older comments
I am having troubles with Matlab trying to call mex versions of functions instead of the regular functions with the same name (within an external toolbox) and then telling me that the mex files are invalid. Strangely, this happens even when the mex files in question are not at all on the search path. When I type "which functionname" I get the path to the correct (non-mex) version of the function. But when that function name is called from the script I get the error. The same scripts with the same path settings worked just fine up until a week or so ago. I tried resetting to the default path and renaming the matlab.prf file to reset all preferences to defaults. No change in behaviour. Could anyone please let me know how to get Matlab to look for functions based on the search path order rather than prioritising those with mex extension?
0 Comments
Accepted Answer
James Tursa
on 12 Nov 2021
You should use debugging to find out why this is happening. Type the following at the command line:
dbstop if error
then run your code. When the error occurs the code will pause at that point with all variables and settings intact. At that point you can use 'which' and 'path' to find out what the situation is and why your code is getting confused.
2 Comments
Image Analyst
on 12 Nov 2021
@Kirsten glad you found the problem - using cd. As the FAQ says, using cd() is almost never necessary. Maybe it's time to re-read all of the FAQ now to learn of other goodies that may help you avoid problems in the future:
More Answers (1)
Image Analyst
on 12 Nov 2021
When you call DLLLoadLibrary you can put the full path (folder + base file name + extension). How did you load/register the mex/DLL file and how did you call it?
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!