Open Thoughts

Matlab to Python

Posted by Cheng Soon Ong on May 6, 2009

I came across the OMPC (one MATLAB per child) project yesterday. No, it isn't a non-profit organisation that is handing out Matlab licenses so that kids in developing countries can enjoy programming. It is an automatic translator from Matlab to Python. It tries to preserve the matlab flavour of the code, so you can carry on writing matlab like code in python. The magic is made possible by python decorators and introspection.

Those python fans out there will throw up their hands in horror ("that's so unpythonic"), but for people who just want to get the job done, it is not bad at all. Also, some useful bits of matlab syntax may become python standards in future, such as the .* operator.

A simple test with arffload.m from our dataformat project crashed at first try. Google app engine didn't like the umlaut in my institution name. After converting Zürich to Zurich, everything worked happily.


chris (on May 6, 2009, 14:19:18)

Another interesting project in this context is "Shed Skin", which is a pythonToC++ compiler:

Not sure how stable it is yet, but it's sure something to keep on the radar.

Soeren Sonnenburg (on May 7, 2009, 10:11:08)

This page has a nice collection of matlab to python links. Basically anything that helps for users that know matlab and want to migrate to python and the same thing (semi-)automatic for programs.

Regarding the .* operator to come to python. I don't think this is ever going to happen ... that proposal above is already years old :-(

Cheng Soon Ong (on May 21, 2009, 11:25:22)

For those who prefer a monolithic installation which has all the packages included, there are two choices which I know of:

Leave a comment

You must be logged in to post comments.