Building upon the work done by the chap that I forked this from, I have edited the mlabwrap project. I liked the look of the Python 3 support - though this is currently untested - which is why I chose to fork from this project. Unfortunately, my Anaconda environment does not seem to like building using Microsoft Visual Studio.
One of the major reasons for using this fork was also because it claimed to allow building on
Windows. However, I haven't gotten it to work. I've maintained the logic that was apparent
in the fork so that, hopefully, it should be possible to make small changes to setup.py
to allow installation on Windows.
This site has an ongoing discussion about installing mlabwrap on Windows, though I've yet to get it to work. I'll happily discuss and fix this fork as appropriate if anyone comes up with any ideas.
NOTE: Matlab root refers to the main Matlab folder, e.g: /usr/local/MATLAB/R2013a/
To install using pip
:
pip install git+https://github.com/patricksnape/mlabwrap.git
To manually set the Matlab root directory, use the following command:
pip install git+https://github.com/patricksnape/mlabwrap.git --install-option="--matlab-root=PATH_TO_MATLAB_ROOT"
To install using setup.py
(with optional parameter --matlab-root
):
python setup.py install --matlab-root=PATH_TO_MATLAB_ROOT
IMPORTANT: THE GLOBAL mlab
OBJECT DOES NOT EXIST FROM VERSION 1.2 ONWARDS
To import mlabwrap we do the following (note the explict call to use of the instance management class MatlabInstance
):
from mlabwrap import MatlabInstance
mlab = MatlabInstance.get_instance()
import numpy as np
Then we can call a function as follows:
mlab.svd(np.array([[1,2], [1,3]]))
If we want to pass in an explicit version of Matlab, we simply specify the root directory:
from mlabwrap import MatlabInstance
mlab = MatlabInstance.get_instance(matlab_root='/usr/local/MATLAB/R2013a')
- Fix
setup.py
to work properly when installing without source - Move mlabwrap into it's own package
- Add concept of
MatlabInstance
management class to allow managing a single Matlab instance. This breaks previous behaiour of just importingmlab
, now we need to explcitly get an instance.
- Fix
setup.py
so that it does correct comparisons for Matlab version numbers
- Change the interface to mlabwrap such that you must explicitly call the init function.
This allows you to pass in the matlab version you want more easily.
This is achieved by way of the
matlab_root
keyword arg that can be passed in to theinit
function. This function is simply the old constructor.
- Rewrite
setup.py
so that it tries to guess where your Matlab folder is - Make
setup.py
work withpip
- Add flag
--matlab-root
tosetup.py
- Fix casting bug in
mlabwrap.cpp
- Remove the old code that tried to use the help command to guess the version as this doesn't work very well
- using system encoding scheme to decode string in
mlabraw.eval
- fix memory leak in
mlabraw.put
caused by chainedchar2mx
andPyUnicode_AsUTF8String