Matlab tries to use mex files not on search path
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
James Tursa
2021-11-12
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 个评论
Image Analyst
2021-11-12
@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:
更多回答(1 个)
Image Analyst
2021-11-12
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!