tags:

views:

341

answers:

2

I'm compiling some MATLAB functions into a C DLL. The exported mlf functions return a boolean value representing whether the function succeeded or not. When the return value is false, I want to find out the error information. I couldn't find a way to do that! (other than compiling and exporting the lasterror() function).

Is there a C interface to get the last error generated by MATLAB's runtime?

+2  A: 

Okay, let's try

mexCallMATLABWithTrap (C and Fortran) - Call MATLAB function, user-defined M-file, or MEX-file and capture error information

#include "mex.h"

mxArray *mexCallMATLABWithTrap(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], const char *functionName);

and

mexEvalStringWithTrap (C and Fortran) - Execute MATLAB command in caller's workspace and capture error information

#include "mex.h"

mxArray *mexEvalStringWithTrap(const char *command);

Those two things were found with Google and a guess or two. Sorry if it's a waste of time.

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/apiref/mexcallmatlabwithtrap.html&http://www.mathworks.com/access/helpdesk/help/techdoc/apiref/bqoqnz0.html

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/apiref/mexevalstringwithtrap.html&http://www.mathworks.com/access/helpdesk/help/techdoc/apiref/bqoqnz0.html

boost
Thanks a lot. But would MEX functions work in the DLL?
Hosam Aly
+1  A: 

What you're asking is way out of my depth. Best I can do is point you at a community which may be able to help. Try first the folk over at GNUMex. After that, perhaps CodeProject and MATLAB themselves.

boost
Thanks. The only problem is that I'm not developing a MEX application, but I'll check these links anyway.
Hosam Aly