Question

I am trying to make some C++ code that uses the Eigen library callable from Matlab. I can't seem to find any pointers on how to do that with Matlab.

Can you compile with matlab making a mex file that uses these kind of libraries? I know you can call MathWorks libraries but that would mean rewriting the code.

Was it helpful?

Solution 2

In principle you can link mex files to arbitrary external dlls/shared libraries, using the -l and -L options. E.g., as taken from http://www.mathworks.de/de/help/matlab/ref/mex.html:

mex('-largeArrayDims',['-L' lapackpath],'-llibmwlapack','matrixDivide.c')

Simply adjust -llibmwlapack and lapackpath to your needs.

OTHER TIPS

In the case of the Eigen c++ library it suffices to copy the Eigen folder from the library to the folder your c++ files are in. The command you than need to use is mex -I./ yourfile.cpp

so you didn't attache any source, i try to give some general advice.

You can have a look at: http://www.mathworks.de/de/help/matlab/ref/mex.html

and in your matlab release should be some examples: matlabroot/toolbox/simulink/fixedandfloat/fxpdemos/

once i had to do that for some c++ code, calling a filter function, written in c++, in matlab.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top