By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,206 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,206 IT Pros & Developers. It's quick & easy.

Calling Python from Matlab

P: n/a
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
Apr 15 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
> 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/~s...hon/pymat.html
Apr 15 '06 #2

P: n/a
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

Apr 15 '06 #3

P: n/a
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.

On 15 Apr 2006 16:00:08 -0700, Michael Tobis <mt****@gmail.com> wrote:
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

--
http://mail.python.org/mailman/listinfo/python-list

Apr 15 '06 #4

P: n/a
Kelvie Wong wrote:
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.

On 15 Apr 2006 16:00:08 -0700, Michael Tobis <mt****@gmail.com> wrote:
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

--
http://mail.python.org/mailman/listinfo/python-list

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

Apr 16 '06 #5

P: n/a
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...

Apr 16 '06 #6

P: n/a
In article <2Po0g.9446$zc1.6404@amstwist00>,
Carl <ph***********@chello.se> wrote:
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.
Apr 16 '06 #7

P: n/a
>>>>> "AgenteSegreto" == AgenteSegreto <na********@gmail.com> writes:

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
Apr 17 '06 #8

P: n/a
"Daniel Nogradi" <no*****@gmail.com> writes:
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/~s...hon/pymat.html


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

Apr 23 '06 #9

P: n/a
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.

Apr 23 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.