python and matlab

Sturla Molden sturla.molden at
Fri Feb 7 06:28:26 CET 2014

Sam Adams <cuongpn at> wrote:

> Thanks Sturla, could you please explain in more details, I am new to Python :)

All the information you need to extend or embed Python is in the docs. 

Apart from that, why do you need Matlab? A distro like Enthought Canopy or
Anaconda has all the tools you will ever need for scientific programming.
Embedding Python is almost never the right solution to a problem. But if
you really need Matlab, you will be far better off by calling Matlab engine
from Python (e.g. using ctypes or Cython). 

There are also packages like mlab and matlabwrap that will help you embed
Matlab in Python:

Apart from that, you can also invoke Python from Matlab like this:

   arg1 = '';
   s = system(sprintf('python %s', arg1));


   arg1 = 'some Python code';
   s = system(sprintf('python -c "%s"', arg1));

Or if you are on Windows, you can use pywin32 to create an ActiveX server
with Python, and invoke that from Matlab.


More information about the Python-list mailing list