MATLAB wrapper for Python
MATLAB wrapper for Python
|License:||GNU General Public License v3 or later (GPLv3+)|
matlab_wrapper allows you to use MATLAB in a convenient way in Python. You can call MATLAB functions and access workspace variables directly from your Python scripts and interactive shell. MATLAB session is started in the background and appears as a regular Python module.
Numerical, logical, struct and cell arrays are supported.
import matlab_wrapper matlab = matlab_wrapper.MatlabSession()
matlab.put('a', 12.3) matlab.eval('b = a * 2') b = matlab.get('b')
s = matlab.workspace.sin([0.1, 0.2, 0.3]) sorted,idx = matlab.workspace.sort([3,1,2], nout=2) matlab.workspace.a = 12.3 b = matlab.workspace.b
- Python (2.7)
- Matlab (tested with 2013b)
- Numpy (1.8)
If you are using matlab_wrapper with MATLAB version and OS not listed below, please let us know and we will update the table.
|OS ||MATLAB||Bits ||Status|
|GNU/Linux||2014a (8.3)||64||only double arrays working |
|GNU/Linux||2013b (8.2)||64||working (py.test OK)|
|GNU/Linux||2013a (8.1)||64||working (py.test OK)|
|Windows||2014a (8.3)||64||working (py.test OK)|
|OS X||2014a (8.3)||64||only double arrays working |
|||OSX support is not very good, because cannot test it. It should work, but if you have problem, let me know and we might figure it out.|
|||I have tested only 64-bit systems. If you are interested in 32-bit version, please contact me per email or open an issue on GitHub.|
|||(1, 2) Due to bug in engGetVariable: Error using save, Can’t write file stdio.|
pip install matlab_wrapper
Issues and Bugs
(last updated on June 17, 2014)
- pure Python, no compilation, using ctypes (good)
- quite raw (ugly)
- memory leaks (bad)
- cool interface, mlab.sin() (good)
- needs compilation (bad)
- not much development (bad)
- similar interface to mlabwrap (good)
- using raw pipes (hmm)
- there is another very old package with the same name (ugly)
- actively developed (good)
- client-server architecture with ZeroMQ and JSON, complex (ugly)
- missing basic functions, there’s no put (bad)
- nice ipython notebook support (good)
Note: There is a nice overview of the available packages at StackOverflow.
matlab_wrapper was forked from pymatlab.
If you find matlab_wrapper useful, please consider making a donation. It will be a great feedback and will further motivate me to improve this software. Thank you in advance.
- Flattr: https://flattr.com/submit/auto?user_id=mrkrd&url=https://github.com/mrkrd/matlab_wrapper
- Bitcoin: 1KwZMQCWJW8VbcmHT2xeMc4wsAeZinLeGe