To call a matlab function from python you have several options:

  • Use a matlab wrapper (mlabwrap, pymatlab)
  • Compile matlab into a c/c++ library and call that
  • Compile matlab into java and call using jython
  • Compile matlab into .net and call from ironpython
  • Compile matlab into java/c#, set up as a service and call the service.

Because the first option is the easiest one with the least overhead I'll explain that one. Follow the following steps:

  1. install matlab (and add matlab to your path)
  2. install pythonxy
  3. install a compiler (mingw, visual studio)
  4. download mlabwrap
  5. python ./setup.py build (you can skip this if you'll know that it will work)
  6. test
  7. python ./setup.py install

In python you can call:

from mlabwrap import mlab
mlab.addpath('openearthpath')
mlab.oetsettings()
mlab.rws_getdatainpolygon()

  • No labels