replacing Matlab with python


Question

i am a engineering student and i have to do a lot of numerical processing, plots, simulations etc. The tool that i use currently is Matlab. I use it in my university computers for most of my assignments. However, i want to know what are the free options available.

i have done some research and many have said that python is a worthy replacement for matlab in various scenarios. i want to know how to do all this with python. i am using a mac so how do i install the different python packages. what are those packages? is it really a viable alternative? what are the things i can and cannot do using this python setup?

1
17
11/21/2009 6:27:48 PM

Accepted Answer

On a Mac the easiest ways to get started are (in no particular order):

  • Enthought Python Distribution which includes most scientific packages you are likely to need. Free for academic/non-commercial use.
  • Macports - up to date with latest releases, so sudo port install py26-numpy py26-scipy py26-matplotlib py26-ipython should get you started.
  • Scipy Superpack - script to install recent svn versions of all the important packages.

I've done exactly this (replace Matlab with Python) about 2 years ago and haven't looked back. The broadcasting in Python, more intuitive memory model and other Numpy advantages make numerical work a complete pleasure. Plus with f2py, cython it is incredibly easy to put inner loops in another language. This is a good place to start - other impressive pages to provide motiviation are PerformancePython and ParallelProgramming. Be sure to understand Pythons "variable is a reference to an object" semantics... after that adjustment everything is plain sailing. One of the coolest things that beats matlab is in 2 lines I run over 8 cores... p = Pool(8); res = p.map(analysis_function,list_of_data) - MATLAB parallels toolboxes are so expensive I've yet to see a University that actually has them.

20
10/21/2014 2:32:41 PM

I've been programming with Matlab for about 15 years, and with Python for about 10. It usually breaks down this way:

If you can satisfy the following conditions: 1. You primarily use matrices and matrix operations 2. You have the money for a Matlab license 3. You work on a platform that mathworks supports

Then, by all means, use Matlab. Otherwise, if you have data structures other than matrices, want an open-source option that allows you to deliver solutions without worrying about licenses, and need to build on platforms that mathworks does not support; then, go with Python.

The matlab language is clunky, but the user interface is slick. The Python language is very nice -- with iterators, generators, and functional programming tools that matlab lacks; however, you will have to pick and choose to put together a nice slick interface if you don't like (or can't use) SAGE.

I hope that helps.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon