I have a platform for python scripting, and I would like to call matlab functions inside. I have found several threads tackling the issue, among them those two
How d
is a great solution for python <-> MATLAB bridging. If something is not working for you just report concrete problems on SO :)
You have to note that mlabwrapper as project has been around for quite a while. http://mlabwrap.sourceforge.net/
I had problems with mlabwrap.cpp recently, for which I found the following github fork
Related Thereis is a copy of mlabwrap v1.1-pre (http://mlabwrap.sourceforge.net/) patched as described here: http://sourceforge.net/mailarchive/message.php?msg_id=27312822
with a patch fixing the error:
mlabraw.cpp:225: error: invalid conversion from ‘const mwSize*’ to ‘const int*’ Also note that in Ubuntu you need to sudo apt-get install csh
For details see http://github.com/aweinstein/mlabwrap
After spending more time, I made a github mirror to update, bugfix and maintain the wrapper https://github.com/ewiger/mlab (patches and pull-requests are welcomed!)
It can be pip installed, i.e.
pip install mlab
I have excluded the cpp implementation for now. In the current way it works as the following:
For Linux/Mac library creates a pipe connection with MATLAB instance. The rest is serialization (partially pointed out by @brentlance), which is done using numpy.
For Windows library uses DCOM to communicate. (But I am still to fix version lookup using registry).
I would recommend to call very high level user-functions in MATLAB (mostly returning logical results or very standard built-in types as matrices) to minimize any communication with MATLAB. This approach is perfect for legacy code, but might require writing some wrapping interfaces to simplify function declarations.
Overall, the code is a bit cumbersome and is a patchwork of many. The core part (now this is matlabpipe and matlabcom) seems to do the job pretty well. Ultimately, I would not recommend mlab for full-scale productive application unless you are willing to spend time testing, bug-reporting, bug-fixing and feature-requesting all of your use-cases.