[SciPy-user] Automatic MATLAB to scipy/numpy/pylab conversion
Wed Jul 9 08:52:44 CDT 2008
On Wed, Jul 9, 2008 at 3:44 PM, David Huard <firstname.lastname@example.org> wrote:
> As a ex-matlab user, I remember being in the position where I would either
> 1. translate matlab codes to python, 2. rewrite the whole thing Python-like.
> I always ended up rewriting the code from scratch because 1. it's a great
> way to learn python, and 2. there things that you can do in Python that you
> don't even dream are possible in matlab, so it's worth rethinking the code
I already know python(i think :) ). My purpose is to preprocess text
from matlab so that i dont have to do the bullwork of typing range(n)
everywhere where 1:n is used etc.
I agree python is millions of times superior to matlab. It has to be,
since it is a _real_ programming language, unlike matlab.
> Besides, a translator that does half the job will likely be seen rather as
> buggy software than as a useful tool for translation. I suggest you look at
> ways to interface matlab and python to launch matlab scripts from python.
I want the guys in my workplace to make the switch from matlab to
python. Thanks to large scale brainwashing(by me), they are receptive
to the idea :)
However, it is too much to expert matlab gurus to leave their
environment of choice and make the switch in a week. So, I hope to use
this tool/module to ease the translation. As a nice side effect, it
also help me right away in changing stuff from matlab to scipy.
> Sorry to be so pessimistic,
I can understand your pessimism. But this does not replace the human
programmer, but makes his life less dull (hopefully!), by doing the
boring work for him.
> 2008/7/9 anirudh vij <email@example.com>:
>> I have a bunch of matlab scripts that I want to convert to
>> scipy/numpy/pylab. There is a nice resource at
>> However, it is tedious and error prone to do these conversions manually.
>> For eg:
>> 1. there is no "end" in python. So all "end" statements from matlab
>> need to be deleted
>> 2. the syntax "for i=1:10" has to be changed to "for i in range(1,11):"
>> 3. special functions from matlab need to be converted to their scipy
>> 4. For comments "%" must be replaced by "#"
>> 5. for array scripting "(<index>)" should be replaced by "[<index>]"
>> 6. Many others........
>> To my mind these examples are prime contenders for automation. A
>> reasonably small python/perl script can do the above(it will get more
>> complicated ofcourse, but the principle is the same).
>> I realize that such a script/module wont be a complete replacement. A
>> human will still need to look at the output python file and edit it.
>> But the script/module can remove the bullwork and leave the human
>> programmer to do more productive stuff.
>> Is there a pre-existing project that accom,plishes this kind of stuff.
>> If not, I would like to start one. Feedback/Suggestions will be very
>> SciPy-user mailing list
> SciPy-user mailing list
More information about the SciPy-user