Matlab is probably as close as you’ll find these days to an international standard for numerical computations. It seems to be taught at almost all universities in one form or another, is loved by engineers, and contains many thousands of lines of highly optimised code. And as well as the base package, there are lots of toolboxes: add-ons which provide functionality in particular areas: image processing, data acquisition, curve fitting and lots more.
Matlab’s interface, general ease of use, power, and extensibility have made it deservedly popular, and it has spawned a vast publishing industry.
As a teaching tool, though, it suffers from one major defect: it’s very expensive. And the add-on toolboxes add to its cost.
There’s therefore the need of a low-cost – preferably open-source – alternative, which can be used by students as a sort of drop-in replacement for experimentation at home, or on their own laptops.
Here is my list of requirements for such an alternative:
- It must install under Windows. This is absolutely necessary for me, at least, since most of my students use Windows. A very few use OSX, and hardly any use Linux.
- It must, as far as possible, be identical in use with Matlab. The commands should be the same, and simple scripts and functions should transfer between the two with no effort.
- It should have a reasonably nice interface, as similar as possible to Matlab’s own. A basic command line only interface running in a terminal won’t cut it with my students.
Note that I’m personally satisfied with a lot less. I have, for example, no problems with a terminal text-based interface and in fact do most of my own computing from just such. However, I’m interested in making things as easy as possible for my own students, many of whom are not hugely computer-savvy.
Octave (more properly GNU Octave) has been around since about 1998, or 1992, depending on how you measure it, and was conceived and initially developed by John Eaton at the University of Wisconsin–Madison to support a course in chemical reactor design. It’s named after one of Eaton’s professors, Octave Levenspiel, who apparently had a genius at “back of envelope” calculations. Anyway, you can read about it on its wikipedia page. As of now, it is up to version 3.2.4, and is a highly mature product, with an emphasis on Matlab compatibility, and supported by an army of users and developers. There are also many add-on packages.
Freemat has been in development since about 2004, mainly by one person, Samit Basu, with help from some others. It seems to have sprung into life very quickly. I can’t find anything online about its history or provenance, but my guess is that it’s a fork or the continuation of some older project. It exists in forms for windows, Linux and MacOS, and has the most Matlab-like interface of all of them. It has a small wikipedia page.
Scilab is in some ways the worthiest alternative to Matlab, in terms of raw power, development (mostly at INRIA, France), and add-on packages. It also has installers for Windows, MacOS and Linux.
There are of course several good comparisons of these software tools, of which “A Comparative Evaluation of Matlab, Octave, Freemat, and Scilab for Research and Teaching” by Neeraj Sharma and Matthias K. Gobbert from the University of Maryland is probably the most far reaching. You can read it here. They don’t make any conclusions as such, but one or two comments are made, such as
“The syntax of Octave and FreeMat is identical to that of Matlab in our tests. However, we found during our tests that FreeMat lacks a number of functions, such as kron for Kronecker products, pcg for the conjugate gradient method, and mesh for three-dimensional plotting. Otherwise, FreeMat is very much compatible with Matlab. Even though Scilab is designed for Matlab users to smoothly utilize the package and has a m-file translator, it often still requires manual conversions.
The tests in this work lead us to conclude that the packages Octave and FreeMat are most compatible with Matlab, since they use the same syntax and have the native capability of running m-files. Among these two packages, Octave is a significantly more mature software and has significantly more functions available for use.”
For numerical solutions of differential equations, the authors state:
“Matlab, Octave, and Scilab have state-of-the-art variable-order, variable-timestep methods for both non-stiff and stiff ODEs available, with Matlab’s implementation being the richest and its stiff solvers being possibly more efficient. FreeMat is clearly significantly weaker than the other packages in that it does not provide a state-of-the-art ODE solver, particularly not for stiff problems.”
Another nice comparison (with lots of screenshots) is at http://www.dedoimedo.com, and is a 2010 discussion on scientific computing. Here’s the conclusion, to save you the trouble of actually opening a web page yourself:
“All three programs have their merits. For Windows users, the simplest choice is FreeMat, while Octave is the most powerful and best run on Linux. Scilab works better on Windows, but it is not fully compatible with Matlab language and requires more effort to master, while leveraging these disadvantages with the fleet of toolboxes and Scicos.
The best thing is, you can use them all together. But if you want to be picky, then I’d recommend you start with FreeMat and Octave and move on to Scilab when you gain enough expertise. “
Some more comments
Freemat seems to be suffering a lack of development, as this chart from ohloh.net shows:
Its current version – 4.0 – while very nice in many ways, has been static now for nearly two years. Interestingly enough, if you enter “help hist” at the Freemat prompt, you are told that this file was “adopted” in Freemat from Octave. This begs the question: how much of Octave has been ported into Freemat? Another problem with Freemat is a seeming low number of users; it simply does not have the large user base of Octave or Scilab.
If compatibility with Matlab was not a concern, then Scilab would be the tool of choice. As well, Scilab comes with Scicos, a dynamic systems modeller similar in style to Matlab’s Simulink. Neither of the other two systems has such functionality. However, Scilab is different enough from Matlab to make conversions between the two (especially of functions and programs) not entirely trivial. There is a conversion program, but like most other conversion programs, it’s a bit hit or miss. Differences between Matlab and Scilab are given here. One thing which always annoyed me in Scilab was that the whos command (which in the other systems gives a list of the user’s variables, with types and sizes), here gives the list of all variables, including built in ones such as %pi and %i.
Octave does not come with any nice interface. However, several third-party interfaces are being produced, of which the most promising for Windows users is GUI Octave. Another fine looking interface is that provided by Xoctave, which at the moment does not seem to be as mature a product as GUI Octave.
Given all the above, my choice is clear: Octave with GUI Octave ticks all the boxes. Almost everything you can do with Matlab can be done in Octave. In fact I use Octave almost exclusively: for various reasons I can’t have Matlab installed on my office computer at work, so all my “Matlab preparation” is in fact done with Octave. This is the system which I’m recommending to my students. Try it yourself! You may be pleasantly surprised.