Python vs Matlab

46,990

Solution 1

IDE: No. Python IDEs are nowhere near as good or mature as MATLAB's, though I've heard good things about Wing IDE. Generally, I find IDEs to be total overkill for Python development, and find that I'm more productive with a well-setup text editor (vim in my case) and a separate visual debugger (WinPDB).

Changing functions: Modules must be reloaded after changes using the reload() built-in function.

import foo
#now you've changed foo.py and want to reload it
foo = reload(foo)

I've switched over myself from MATLAB to Python, because I find that Python deals much better with complexity, i.e., I find it easier to write, debug and maintain complex code in Python. One of the reasons for this is that Python is a general purpose language rather than a specialist matrix-manipulation language. Because of this, entities like strings, non-numerical arrays and (crucially) associative arrays (or maps or dictionaries) are first-class constructs in Python, as are classes.

With regards to capabilities, with NumPy, SciPy and Matplotlib, you pretty much have the whole set of functionality that MATLAB provides out of the box, and quite a lot of stuff that you would have to buy separate toolboxes for.

Solution 2

I've been getting on very well with the Spyder IDE in the Python(x,y) distribution. I'm a long term user of Matlab and have known of the existence of Python for 10 years or so but it's only since I installed Python(x,y) that I've started using Python regularly.

Solution 3

You might also want to check out some of the answers in the following thread, although they don't address your 2 major concerns:

Should i switch to Python?

I'm also a total convert from Matlab:

  1. I have yet to use a full featured Python IDE, but have gotten on pretty well in IPython in combination with Matplotlib, Numpy, Scipy, etc. I actually use the Enthough Python Distribution that comes preloaded with most of the scientific/quantitative packages I need. I've also heard good things about Python(x,y) and Sage

  2. Maybe other IDE's handle this but in IPython I use autoreload which works fairly well.

As others have mentioned, since the numerical/quantitative libraries came to Python instead of a numerical library hacking a language on top, you have an incredible amount of flexibility that you don't have with Matlab. Also the Python community, especially in the numerical/quantitative areas, is really quite fantastic.

Solution 4

I've been in the engineering field for a while now and I've always used MATLAB for high-complexity math calculations. I never really had an major problems with it, but I wasn't super enthusiastic about it either. A few months ago I found out I was going to be a TA for a numerical methods class and that it would be taught using Python, so I would have to learn the language. What I at first thought would be extra work turned out to be an awesome hobby. I can't even begin to describe how bad MATLAB is compared to Python! What used to to take me all day to code in Matlab takes me only a few hours to write in Python. My code looks infinitely more appealing as well. Python's performance and flexibility really surprised me. With Python I can literally do anything I used to do in MATLAB and I can do it a lot better.

If anyone else is thinking about switching, I suggest you do it. It made my life a lot easier. I'll quote "Python Scripting for Computational Science" because they describe the pros of Python over MATLAB better than I do:

  • the python programming language is more powerful
  • the python environment is completely open and made for integration with external tools,
  • a complete toolbox/module with lots of functions and classes can be contained in a single file (in contrast to a bunch of M-files),
  • transferring functions as arguments to functions is simpler,
  • nested, heterogeneous data structures are simple to construct and use,
  • object-oriented programming is more convenient,
  • interfacing C, C++, and fortran code is better supported and therefore simpler,
  • scalar functions work with array arguments to a larger extent (without modifications of arithmetic operators),
  • the source is free and runs on more platforms.

Solution 5

We use the Wing IDE for Python development. It is quite well featured, has integrated debugging support, and can be connected to the profiler of your choice.

Regarding (2), I know exactly what you mean since I miss that very same feature from Lisp, and so far as I know you need to actively reimport the libraries after changing them. This isn't a real hangup, though, since you can easily write (once) a small function that does that for every module you care about, and then put that function on a key macro so all you have to do is eg hit CTRL-T after changing code.

Share:
46,990

Related videos on Youtube

Rich C
Author by

Rich C

Updated on July 09, 2022

Comments

  • Rich C
    Rich C almost 2 years

    I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).

    1. Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler?

    2. When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.

    • Sven Marnach
      Sven Marnach about 13 years
      ad 2: Yes.
    • Martijn van Wezel
      Martijn van Wezel over 8 years
      Matlab is a mathematical programming interface that is also quit fast. This is very familiar with python only Matlab is faster languages then python. The use of Matlab was that using figures different graphs is easier with Matlab. After executing an program Python the output is printed or saved what the user programmed, but in Matlab the data is still saved and errors in the program can be solved and that part re-run can start from that line instead of restart hours of simulation and testing. And No, I am not capable writing the first run always 100% correct code.
    • Antonello
      Antonello over 6 years
      @Martijn Ehmmm... also in python you can run code interactivelly, running just the lines you want nd make changes..
    • Martijn van Wezel
      Martijn van Wezel over 6 years
      @Antonello I did not see any good example for that. Main reason I use Matlab is, because it's free for me and no library mess (and symbolab)
    • Antonello
      Antonello over 6 years
      @MartijnvanWezel ..just use a Python IDE, select the code you need to run and choose "run block" or similar from the menu.. If you don't like that Python needs to install external libraries to do numerical computation, you may like Julia (with the Juno IDE).. it's fast, it has everything for numerical computation already in core and the syntax is VERY similar to Matlab (see this cheat sheet)
  • SCFrench
    SCFrench about 13 years
    I'm curious - what kind of flexibility are you referring to? Could you give an example or two?
  • Chinmay Kanchi
    Chinmay Kanchi about 13 years
    scipy has a fairly comprehensive optimization toolkit. docs.scipy.org/doc/scipy/reference/optimize.html
  • JoshAdel
    JoshAdel about 13 years
    @SCFrench (no offense to your employer - Matlab served me well during grad school), but Python does the following better because it is a full-fledged open source programming language IMHO (1) OOP -- I haven't used the newest Matlab incarnation, but the implementation when I was using Matlab left a lot to be desired. (2) String handling (3) Free to run/distribute on any platform/machine -- this is the biggest flexibility issue for me. This is a partial list and I acknowledge that Matlab is highly capable and has some nice qualities, but the projects I work with have made me a convert.
  • JoshAdel
    JoshAdel about 13 years
    There are several neural network libraries for python, for example pybrain.org. I don't know how they compare to the Matlab toolkit, but (1) they are free and (2) I wouldn't write them off out of hand because there are some very smart people developing a lot of these projects.
  • fedvasu
    fedvasu about 13 years
    pardon me, if my tone was not clear,i'm not trying to write anyone off...(i hope they'd be better than existing ones) learning a particular toolbox how it works and how it handles variety of cases is a huge investment,i did some good work using neural network toolbox of matlab(my institute has several licenses .. i need not worry about money!!) I was quite satisfied by the speed and realiability of the nnet toolbox. i was doing this small proj along side my regular cuuriculum (that sem is considered hectic!), i could finish the job , so bottom line is i'm a bit biased.
  • SCFrench
    SCFrench about 13 years
    I'm not trying to start an argument or anything; I'm genuinely interested in ways to improve MATLAB. Thanks for the info!
  • William Payne
    William Payne about 12 years
    As an aside, I do miss some MATLAB language features, and I would not (yet) consider Python a drop-in replacement, although that might have more to do with where I am on the learning curve than anything else.
  • lukecampbell
    lukecampbell almost 12 years
    PyCharm is awesome, I don't use Matlab so I can't compare the two but have you tried PyCharm?
  • Boris Gorelik
    Boris Gorelik almost 12 years
    PyDev is an excellent IDE. PyCharm is good too.
  • endolith
    endolith almost 12 years
    I suspect Spyder is a much better than Wing as Matlab replacement.
  • lukecampbell
    lukecampbell almost 12 years
    Correction to my last comment, vim is infinitely better than all of them. PyCharm was just good at refactoring methods.
  • dhj
    dhj over 11 years
    I personally like PyDev + vwrapper. It's the best of both worlds -- vim like editing in a full ide.
  • TraceKira
    TraceKira over 6 years
    Visual studio 2017 has built in support for python ! Its amazing . Visual studio 2017 Professional is also free !
  • Cris Luengo
    Cris Luengo almost 6 years
    Some of your arguments are wrong. "syntactic requirements of adding curly braces or semi colons" I find it hard to remember to add the colon at the end of a for statement. "Python’s better readability" That depends on what you're used to, they both have syntax that is cryptic at times. "the developers of Matlab offer no such interaction" Yes they do. Plus paying for a license gets you customer support. [continued]
  • Cris Luengo
    Cris Luengo almost 6 years
    [continued] "There is no Matlab counterpart to Python’s import statement" Yes there is, it is called addpath. "Python offers a wider set of choices in graphics package and toolsets" MATLAB has the best publication-quality graphics available.
  • Xukrao
    Xukrao almost 5 years
    @ChrisLuengo A strong statement like 'software X is the best for Y' must be backed up by strong arguments. What features does MATLAB have that you believe enable it to produce better-quality graphics than Matplotlib?