Home » from me to you

Peep into my toolbox 2: Matlab

7 Januar 2011 1,100 views No Comment

Matlab, I have to say it, is fabulous. This may be controversial, but I’d like it not to be. Matlab is a programming language for trying stuff out, prototyping, and research. I’m aware of some alternatives, and I do use them quite often, in particular Python with Numpy/Scipy and the statistical programming language R. However, for me, neither of them are quite as comfortable as Matlab. Music processing research works for me if I do it this way: Matlab for discovery and prototyping, bash scripts for organising execution and output, C++ for coding stuff where speed and memory-efficiency is important, and Python for everything else. In this setup, here’s what I most enjoy having Matlab for:

  • Simple maths-like syntax. Both Python and R keep wanting to make me do things their way. They may be more consistent and more versatile as programming languages, but Matlab is more immediate. Most obviously, I can write a vector just like [1, 2, 3], and I don’t have to write array([1, 2, 3]) (Python) or c(1,2,3) (R). Not terrible you may think, and I agree. But if I can choose I will choose the simplest for prototyping.
  • It comes with basic audio import/export (wav) and a big set of toolboxes that get you started on almost any kind of signal processing.
  • Integrated graphics. The best integrated graphics is a close race between R and Matlab, with a slight advantage for Matlab in 3D graphics, and a slight advantage for R in the ease-of-export, in my experience. Python has matplotlib, but I find the handling not practical. The thing is that I need graphics to quickly check what I’m doing when I’m trying out new stuff (as opposed to publishing), and that’s an estimated 95% of all times, so nifty integration counts. And that works best for me in Matlab, I can dock and undock to/from the IDE, have several plots, close the plots without stopping processing. I can’t stress enough how much continuous checking and exploring data visually influences my research (I think: positively). In fact, I’ll make another sentence about it: visualising research data and results is of utmost importance. Exporting plots can be a bit of a nightmare in Matlab, but I’m coping.
  • Integrated editor/debugger/profiler. The integration of the editor in Matlab is nice. You can separately run partial code blocks, debug, profiles, and that’s just nice if you don’t know what your doing, which happens often in my case, especially when starting a new project.

Good communities exist for R (only drawback: you can’t blooming goole for it!), Python and Matlab alike.

This is it really. Now I know that there are severe drawbacks of Matlab (let’s recall: speed, memory, graphics export; let’s add: text processing), many of which can be overcome by using different tools for things Matlab is not good at. In fact, since I’ve been able to code fast stuff in C++, I have realised that the combination is really great.

But let’s also mention the big drawback: Matlab is very very expensive. Well, maybe not the skeleton student version, but everything else is (toolboxes, compiler, non-student license). That means that you have to be lucky to work in an environment where your software is paid for, or you must be nuts to pay for it yourself. At the moment, I am a spoilt child, but it’s also expensive to everyone else on the planet, so if you want to share your Matlab code, you’ll get little exposure in non-rich circles, or the people it could help can’t use it (thanks to Chris Cannam for reminding me of this).

So I use Matlab with pleasure, but mixed emotions. Maybe in a few years Python will have genuinely caught up on features that I want from a prototyping language, or something else emerges. Or I will start working on something else, and my preferences will shift. Till then, I will continue to use Matlab. If my employers pay for it.

Comments are closed.