# Getting by without matlab

Posted in hacks and kludges on Sunday, February 10 2013

Matlab is a key part of any engineers education, at least in these parts. Matlab is the workhorse in most classes I've taken for everything from statistics and regressions to control theory. However matlab costs money.

So as a broke-ass student you have the option of hoping that your school or department has a license for you -- my department doesn't -- or you use the computer labs on campus. Paying for it is just out, as is piracy -- we are all upstanding citizens here.

Open source rides to the rescue in the form of octave. Which is available for windows and macs as well as linux, etc.

Most of the functions in matlab are available in octave and there are many additional tools on octave forge. I've noticed, for example, that some of the matlab functions for nonlinear regression are not in octave, though that functionality is available in the optim package, just wrapped up in a different way.

For right now I am taking a class in modelling process dynamics and so I need to be able to build state space and transfer function models of linear systems. The tools to do this are available from octave forge as the control package.

Now if you are like me and run Ubuntu (12.04) you use apt and install octave and octave-control, however currently this just installs octave 3.2 and the control package seems to be missing things (like the initial function for one).

There is an alternative source of octave that is more up to date, and if you install the octave dev tools you can get packages directly from octave forge:

:~$sudo apt-add-repository ppa:octave/stable :~$ sudo apt-get update
:~$sudo apt-get install octave :~$ sudo apt-get install liboctave-dev
:~\$ sudo octave
octave:1> pkg install -forge control


You need to install liboctave-dev otherwise octave will be unable to install packages, complaining about a missing mkoctfile. Also note that octave can install the package in your home directory, you don't need to sudo octave to install whatever package you want, I just wanted the package to be installed globally.

At this point you can run octave from the command line, which isn't too thrilling if you are used to the fancy matlab gui. There are a bunch of front ends you can install, my favourite is Cantor, purely because it acts as a front end for lots of things, so I can have Sage or whatever running at the same time. If you are used to MAPLE or Mathematica worksheets Cantor is pretty similar.

Alternatively there is scilab which is also a matlab like thing, and it includes something like simulink called xcos.

tags: matlab, octave,