- Source your python environment. For me, it is anaconda with the name of virtual environment
base
.
source activate base
- Change your directory to where you installed MATLAB
cd /usr/local/MATLAB/R2019a/extern/engines/python
Here, my MATLAB is installed in /usr/local/MATLAB/R2019a
- Install matlab engine for python
python setup.py install
This will install matlab engine for python in your current python virtual environment
- To test whether it works:
import matlab.engine
If the import is successful, you won't get any error message
I have a matlab class in /home/ivory/VersionControl/Jmscslgroup/ROSBagReader
. I want to use it from python.
I will do it as follows:
eng = matlab.engine.start_matlab()
eng_return = eng.addpath('/home/ivory/VersionControl/Jmscslgroup/ROSBagReader')