views:

264

answers:

3

Hi, Is it possible to run MATLAB functions from within Python? I search the internet, I could only find PyMat. The bad thing is the compiled version only supports Python2.2 and I am using 2.6. So I tied to download the source code, so I can compile it for myself. But I cannot compile it, VC++ express seems not to have the necessary functionalities to compile it. Does anyone have the compile version for PC? or any substitutes for PyMat? Thanks

+2  A: 

PyMat looks like it's been abandoned.

I'm assuming you are on windows so you could always do the simplest approach and use Matlab's COM interface:

>>> import win32com.client
>>> h = win32com.client.Dispatch('matlab.application')
>>> h.Execute ("plot([0 18], [7 23])")
>>> h.Execute ("1+1")
u'\nans =\n\n     2\n\n'

More info here

Mark
A: 

see this page: http://ompc.juricap.com/

Ballooning
A: 

Another option is Mlabwrap:

Mlabwrap is a high-level python to Matlab® bridge that lets Matlab look like a normal python library.

It works well with numpy arrays. An example from the home page:

>>> from mlabwrap import mlab; from numpy import *
>>> xx = arange(-2*pi, 2*pi, 0.2)
>>> mlab.surf(subtract.outer(sin(xx),cos(xx)))
ars