Calling Python from Matlab

C

Carl

I am desperately looking for a way to call Python from Matlab. I have become
used to Python's rich syntax and large number of libraries, and feel
ridiculously clumsy being stuck with Matlab's rather restricted facilities
for doing other things than standard mathematical work.

Does anyone know of good techniques (or readily available software) for
achieving a cross-language support between Python and Matlab?

Carl
 
D

Daniel Nogradi

I am desperately looking for a way to call Python from Matlab. I have become
used to Python's rich syntax and large number of libraries, and feel
ridiculously clumsy being stuck with Matlab's rather restricted facilities
for doing other things than standard mathematical work.

Does anyone know of good techniques (or readily available software) for
achieving a cross-language support between Python and Matlab?

Carl

Perhaps you will find this useful:

http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html
 
M

Michael Tobis

I'm afraid I can't be very helpful to you, but you could be most
helpful to some of us.

Can you elaborate on what specifically you found difficult? In some
circles Python is regarded as a direct competitor to Matlab. Your
preference for Python for "other things than standard mathematical
work" in a scientific or engineering context could be most useful if
you have some real-world examples.

Also, can you elaborate on what (if anything) it is about Matlab that
you feel you can't replicate in Python? Are you aware of matplotlib and
numpy?

thanks
mt
 
K

Kelvie Wong

I have a suspicion it is the collaborative effort that is the problem
here -- I try to use Python whenever possible for
engineering/numerical analysis, but the established industry standard
(for most disciplines of engineering) is still MATLAB.

Although Python is arguably better in most respects, especially being
a full-blown programming language (and modules such as SciPy and NumPy
are just great), but it's hard to expect your co-workers to be using
Python for analysis also.
 
C

Carl

Kelvie said:
I have a suspicion it is the collaborative effort that is the problem
here -- I try to use Python whenever possible for
engineering/numerical analysis, but the established industry standard
(for most disciplines of engineering) is still MATLAB.

Although Python is arguably better in most respects, especially being
a full-blown programming language (and modules such as SciPy and NumPy
are just great), but it's hard to expect your co-workers to be using
Python for analysis also.
This is exactly my problem!

I have to use Matlab at work because it is the language my fellow co-workers
use. At my previous work we used Python as our language of choice. I never
had had to use Matlab because Numeric, numarray, SciPy, etc were already
there. These libraries worked beautifully with Python!

My major problem with Matlab is not the language; it is a quite nice
language, comparable to Python and R. The problem is the lack of libraries
for doing things that are not basic mathematical stuff, such as reading
text from files, handling strings, pickling, etc. When you are used to
Python's large number of high-quality modules you feel disadvantaged being
confined to using only Matlab.

I have learnt that Matlab provides a facility for executing Perl commands
and running Perl scripts, but I have not used it yet. It would have been
nice to have the possibility of mixing Matlab and Python code, by using
inlining, for example!

One option could be to use Perl to call Python from within Matlab.

Carl
 
A

AgenteSegreto

I've been a Matlab user for years and have recently started using
Python with matplotlib and NumPy for most of my work. The only thing I
found that is still lacking is a 3D capability in matplotlib. I was
trying to visualize a hill climbing algorithm and I couldn't find
anything comparable to Matlab's 'surface', 'mesh', or 'plot3'. I think
VTK would have done the trick but there's only so much time in the
day...
 
L

Lawrence D'Oliveiro

Carl said:
My major problem with Matlab is not the language; it is a quite nice
language, comparable to Python and R.

Having done a bunch of MATLAB GUI programming for a client a few years
ago, I would not agree that MATLAB is a "nice" language at all. The
basic matrix stuff is fine, but all the structure stuff had a definite
feling of being tacked on. The GUI stuff in particular was very fiddly
to do.
 
J

John Hunter

AgenteSegreto> I've been a Matlab user for years and have recently
AgenteSegreto> started using Python with matplotlib and NumPy for
AgenteSegreto> most of my work. The only thing I found that is
AgenteSegreto> still lacking is a 3D capability in matplotlib. I

There is some progress being made on this front -- in svn are a
collection of classes for basic 3d plots (plot3, mesh, surf) but the
interface to these is still under development. We hope they will be
included in the next major release 0.88.

You can see some examples here:

http://www.scipy.org/Wiki/Cookbook/Matplotlib/mplot3D

Also, there is a master's student who will be working on extending mpl
3d capabilities as part of her master's project, so expect some basic
functionality in the near future.

We certainly don't aim to compete with VTK or other full-blown 3D
solutions like Mayavi

http://mayavi.sourceforge.net/
http://www.enthought.com/enthought/wiki/MayaVi
http://www.scipy.org/ArndBaecker/MayaVi2

but most agree it would be nice to have some support for basic 3D
plotting in matplotlib.

JDH
 
A

Alexander Schmolck

Daniel Nogradi said:

I'd recommend looking at

<http://mlabwrap.sourceforge.net/>

instead (but then I'm the author). It's based on pymat but contains several
critical bugfixes and a high-level interface from python to matlab (e.g. you
can just do mlab.plot([1,2,3]) or x = mlab.sin(3)). I'll need to update a
couple of things, but on the whole it appears quite stable -- people have
succefully used it under windows, linux and os x.

'as
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Also, can you elaborate on what (if anything) it is about Matlab that
you feel you can't replicate in Python? Are you aware of matplotlib and
numpy?

The features provided by some matlab 'toolboxes' (libraries in
matlab-speak)
are lacking, and are beyond what numpy + scipy may provide. Some
projects
done in Matlab could easily be translated to Python, but probably not
the control
engineering kind for example -- the algorithms provided by the control
toolbox,
the identification toolbox, etc. are standard tools in the field, and
were
implemented by domain experts.

Don't get me wrong. There are A LOT of scientific projects that can be
done
with Python, and I'd rather cut my hand than do some Matlab programming
when I can avoid it.

I also believe that the work involved in the proper installation of
numpy +
scipy + matplotlib is far beyond the average Matlab user ability (check
the
amount of "installation problem" on the numpy mailing-list ...). But
for sure,
the work done in these libs is just great and their community is
extremely
reactive and helpful.

Last thought: the "All Python behavior in the presence of infinities,
NaNs, and
signed zeroes is a platform-dependent accident" meme still worries me
from
time to time ... But, hey, that's probably just me :)

Cheers,

S.B.
 
Joined
Nov 9, 2009
Messages
1
Reaction score
0
I use neuron software which is python enabled.
I want to combine neuron and matlab artificial neural network toolbox in my research
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top