Directory path for .m files and .dll files

I have Matlab R2011a. When functions defined in files with extension .m and and .dll, .maxglx, mexglx, and .c files are all in one folder, I can not call the user defined functions in Matlab command line. As though these functions don't exist. However, >>help function_name CAN find the function. The error message is:
??? Undefined function or variable 'user defined function name'.
Summary: there is one filder with .dll, .m, .c, .mexglx files. I CAN NOT call the functions defined in .m. When I move the function to a different folder with no other .c or .mexglx files, then I can call the user defined functions.
R/ Bahman Darian

5 Comments

Are the problem functions the ones in the .m files?
Or are you saying that if for any one function name if you isolate the .m (for help info) and .c and .mexglx for the function into a distinct directory without the .c and .mexglx that are for other functions, then it works then?
Or is the issue that it cannot find user-defined functions inside the .dll but can find them inside .mexglx ?
I am a bit confused about which operating system you are using, as .mexglx is for Linux but .dll is not for Linux.
yes, the problem functions are the ones in .m files. The platform is Windows 7 professional, 64-bit operating system. There is a .m function called sinc defined in a file called sinc.m when I type >> help sinc, help comes back with a description of sinc fetched from sinc.m file. sinc.m is in a folder with other functions and files with .c, .dll, and .mexglx files. >> sinc(1.5) gives me an error message that states sinc.m can not be found. When I cut sinc.m and put it in a new folder called test, then everything is ok. sinc(1.5) returns an answer. After every file movement, I set the path so Matlab knows where sinc.m is located.
Is there a sinc.dll file? If so then MATLAB might look in there for the executable code instead of looking in the .m file for the code. I am not positive about this on 64 bit MATLAB; if you are using 32 bit MATLAB then it should certainly look at the .dll . But does the .dll contain 32 bit or 64 bit code?
There is no sinc.dll file. I tried reading .dll files using Notepad. it didn't work.
How could you open the .dll files in Notepad, when there are no .dll files?
Is the error message really "??? Undefined function or variable 'user defined function name'." or is "user defined function name" a replacement for the forum? Please post a copy of the code you are using and of the error message. Explaining what you want to do and interpretations of the error message are not useful.

Sign in to comment.

Answers (2)

Jan
Jan on 4 Feb 2013
The help command looks for the M-file in every case, while calling a function from another M-function prefers the compiled Mex function. This function is found, when the folder is either the current folder (see cd) or if it is included in the path (see addpath or pathtool).
The .c file and compiled files which do not belong to your operating system (e.g. DLL under Linux) are ignored.

1 Comment

Also, if you're on 64-bit Linux with 64-bit MATLAB, you need to get the 64-bit MEX-files (which have an extension .mexa64), the ones with .mexglx extensions are for 32-bit Linux.

Sign in to comment.

Bahman
Bahman on 8 Feb 2013
Please see the comment in response to Walter Robertson's comment. The platform is Windows 7 professional, 64-bit operating system. I never used Mex functions on Matlab/windows platform.

2 Comments

Jan
Jan on 8 Feb 2013
Edited: Jan on 8 Feb 2013
So please ask the question agian as clear as possible. Which commands to you try to run, what does "which sinc -all" reply, which error message do you get? It does not matter if you have called MEX or if compiled files have been created by somebody else.
Did you check the integrity of the file system already? This is most likely not the problem, but a good practice in general.
@Bahman: Your DLLs are probably 32-bit versions and won't work on 64-bit MATLAB. You can either recompile the MEX-files using the "mex" command in MATLAB for 64-bit Windows, or install 32-bit MATLAB on your 64-bit machine. (Note that the .dll extension was used for MEX-files in older versions of MATLAB. It is now recommended to recompile to produce the platform specific .mexw32 or .mex64 extensions.)

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Asked:

on 4 Feb 2013

Community Treasure Hunt

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

Start Hunting!