Location required for mex files?

조회 수: 3 (최근 30일)
Bob Knighten
Bob Knighten 2011년 4월 11일
I am using a toolkit downloaded from the File Exchange. It calls for using mex to compile some .c files for speed. There are also .m versions of these same files. If one of these compiled functions is called from a .m file in the same directory as the .mex files, the .mex files are used and the speed is excellent. But if the .m file is located elsewhere instead the uncompiled (i.e. .m version) is used and the speed is bad. All files in question are in the path. Is there something else that can be done so the .mex files will be used?

답변 (3개)

Robert Cumming
Robert Cumming 2011년 4월 11일
If you can ensure that the mex file is towards the beginning of the path string it will override the m files, see http://www.mathworks.com/help/techdoc/matlab_prog/f7-58170.html
  댓글 수: 1
Bob Knighten
Bob Knighten 2011년 4월 20일
This would have solved the problem but for an odd reason because I would have moved the directory in which the files were located out of the bad location in the matlab/toolbox directory tree. See my answer below.

댓글을 달려면 로그인하십시오.


James Tursa
James Tursa 2011년 4월 12일
My advice would be to put the mex files in the same directory as the same-named m-file. That way the mex file will always be called to execute the function, but the m-file can still be used for help text.
  댓글 수: 1
Bob Knighten
Bob Knighten 2011년 4월 20일
That was already true, but as explained below the directory itself was misplaced.

댓글을 달려면 로그인하십시오.


Bob Knighten
Bob Knighten 2011년 4월 20일
The answer, not likely to be found from my description of the problem, is in the Mathworks documentation: "We strongly recommend that you save any MATLAB code files you create and any files provided by MathWorks that you edit in a folder that is not in the matlabroot/toolbox folder tree." http://www.mathworks.com/help/techdoc/matlab_env/f8-28521.html
I violated that recommendation with the odd result that even though I made sure the relevant folder was in the path only the .m file was visible, not the .mex file. In any case moving the folder holding the .m and .mex files out of the matlabroot/toolbox folder tree solved the problem.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by