## Octave, a free Matlab clone, and a bit more

In the engineering world, some applications are de facto standards such as AutoCAD, LaTeX, EndNote, Mathematica and last but not least, Matlab. The Matlab language is well known for its versatility and efficiency. Matlabs major problem is pricing, be prepare to spend more than $1000 for the standard package and an extra $100 per toolbox. However there is an open source alternative that is comparable to Matlab. Octave.

Octave is a nice free alternative to Matlab that permits scientists to process data or to use it as a general purpose (graphic) calculator. In some cases Octave's syntax is slightly different from Matlabs’ but standard functions such as the creation of matrices, concatenation of matrices, 2D and 3D plots, data interpolation and numerical differentiation and integration are exactly the same. Octave can be installed via Fink or DarwinPorts but can also be compiled from source available at http://octave.sourceforge.net.

**Command Line Interface (CLI) vs. Graphical User Interface (GUI)**

Since Matlab 6.0, the software is no longer a CLI-only tool anymore some functions are accessible using a GUI (Graphics, Curve Fitting ...), Octave is a pure CLI application and in my opinion it is a good thing.

**Octave as a (graphic) calculator**

Octave can be used just as a calculator, by typing commands such as '2+2', you get 'ans =4'. You can even use more complex functions such as ^(power), cos, sin, tan, fft, linear algebra ... Octave is thus a perfect tool to look into the evolution of a function or to plot experimental results stored in a text file (you can import the data using the load function). Different types of 2D and 3D plots are available and the graphs produced look miles better than what you can get with MS Excel. Curve fitting is available (polynomial, or any function you like using optimization routines).

Octave would be prefect in this regard if it had Matlab's ability to interpret LaTeX commands natively for titles and axis labels.

**Octave as a programmable calculator**

All the Octave functions can be grouped in a file (.m extension) leading to scripts or functions. A function usually leads to a result (output) which is dependent on the function's input whereas a script is just a chain of statements (which can also be scripts of functions).

Octave permits the use of standard test and loops structures such as if, for, while and switch. Thus it is a very good software to teach algorithm development. For the beginner, the fact that variables don't have to be declared is a real positive point but comments are then highly recommended to make sure that your programs will be readable by someone else.

From a more scientific point of view, Octave is perfect for Engineering to solve Partial Differencial Equations using one of the built-in solvers or by writing your own finite difference program.

**The benefits of Open Source**

Octave can also be seen as a platform designed to receive plug-ins, which are called toolboxes. These toolboxes are numerous and are mainly developed by academics in the following disciplines:

1. Image and video processing

2. Audio processing

3. PDE solvers, finite elements or finite differences methods

4. Signal processing: Fourier transforms ...

5. Data processing: interpolation, curve fitting ...

6. Symbolic maths

7. Numerical computations

Anyone can develop their own toolbox should the need arise. More important they can then share their toolbox with the rest of the Octave community. Most of the time, the solution to your problem has already been partially or completely developed by someone else.

An additional benefit of Octave is that the community is very active and that it is very likely that the Octave user group will help if you have problems using the software, from compilation of the sources to the development of your own libraries. That’s not to say that Matlab’s user community isn’t the same, rather that just because the software is open source and free, it doesn’t mean you can’t get help from an equally vibrant user base.

**Limitations of Octave**

First as it's free, do not try to perform a complete side by side comparison of Octave and Matlab's features, of course the Matlab is more feature complete. The lack of a Simulink equivalent in Octave is a problem for Process Control engineers.

Like Matlab, Octave is interpreted and can therefore be quite slow. If you try to solve big problems you can still use C++ routines directly in Octave to help it run faster, but for small problems, you develop the solution ten times faster with Octave than the time you would have spent developing the program in C++. Octave also lacks a built in editor but Scintilla will do the job.

Most of these limitations are not found in another Matlab clone: Scilab, is being developed by a French consortium, but my main problem with Scilab is that its syntax is quite different than Matlab's. Therefore if you need to maintain as much compatibility as possible with Matlab, Octave is the more appropriate choice.

## Comments

## About Scilab

I was half through the paragraph were you were talking about Octave's limitations on simulation, and I was immediately thinking about Scilab. Then I saw you were already mentioning it, I just wanted to give you the thumbs up. Scilab is great, but you cannot reuse Matlab code with it…

## M-file editor

I work a lot with matlab on my old powerbook but I find that it feels very sluggish. I assumed this is caused by the java implementation of the gui. Therefore I disable this with the '-nojvm' setting and run matlab from the terminal. It responds much better now but unfortunately I also lost the build-in editor. At the moment I am using textwrangler with syntax highlighting for Matlab. It works just fine but I was wondering if there are other (better?) m-file editors out there that have a carbon/cocoa gui.

Also I am looking into using a replacement for matlab, either scilab or octave. I intend to test-run both. I already googled for comparison but the results were minimal. I would like to know which is best and why one of the two could be preferred. I intend to use it for image and data analysis.

Thanks, Ferry

## MATLAB Slow?

MATLAB used to be interpreted when executing loops, but now it has a just-in-time (JIT) compiler. I've personally seen speed ups of over 80X since version 6.0 was released. Matrix operations were always fast. In truth, It is very unlikely that C++ code is going to be significantly faster than a straight MATLAB implementation, and every possibility of being slower. By the way, MATLAB is spelled with all caps. Also, MATLAB is $1900 and most of the toolboxes are alot more than $100. That said, for professional work, it can be a good investment as the quality of the numerics is high and the Mathworks support is excellent.

Eric

## Octave

http://hpc.sourceforge.net has links to Octave and SciLab. Note that you can get binary copies at the Octave home site. If you want to do graphics, you'll need GNUplot and Aquaterm (AquaTerm is used by GNUplot on the Mac). GNUplot/AquaTerm require X11 to be installed. I've tried it out using our DiffEq sample manuals and it all works pretty well.

SciLab is available as a binary via its homepage as well...Fink/DarwinPorts and compiling are not necessary.

I have a dual-core Mini with 1GB RAM.

## If you are concerned about

If you are concerned about performance and/or price you might look at O-Matrix, http://www.omatrix.com/overview.html. Even when compared with MATLAB' JIT compiler, it will provide significant performance gains, http://www.omatrix.com/bench.html. And, although not free or open source, it is very affordable.

## Try using emacs as your

Try using emacs as your m-file editor. If you download matlab.el (http://www.mathworks.com/matlabcentral/files/104/matlab.el) and edit your .emacs file accordingly, you get an m-file editor in emacs that is very similar to the MATLAB editor.

## TextMate as editor

TextMate (http://macromates.com/) is the "obvious" 8^) choice for an editor for Octave. This is one of the most customizable editors around and one needs to spend a bit of time with it before achieving grokage. There is currently MATLAB syntax coloring available but there still remains some work to make a bundle for it before the full power becomes available. Look at some of the videos on the site (for Rails and Python) and you'll begin to see the potential of this editor. And it's all pretty Cocoa, too.

## CAPITAL LETTERS

I THINK IT IS MUCH BETTER TO USE NORMAL SPELLING FOR NAMES WITH A CAPITAL LETTER AS THE FIRST CHARACTER. WE CAN SPELL Matlab JUST LIKE WE WANT TO, ANYWAY EVERYONE WILL UNDERSTADN WHAT WE MEAN AND NOONE WILL BE ANNOYED BY SHOUTING CAPITALS.

Martin

## MATLAB Startup

That's the snippet that MATLAB displays when I start it up. That, and the fact that the directory it installs itself in is given all caps, suggests that it should be referred to as MATLAB.

## Smultron; Sym

I use Smultron for edit m-file

However, now i'm nto able to use "sym" on my Octave+Octave-Forge installation, because i can't compile and install CLN and GiNac.

## Yet another MATLAB clone: Sysquake from Calerga

Sysquake is another "MATLAB clone" for Mac OS X Aqua

(as well as Windows, Linux and PalmOS(Lyme)), whose syntax is quite

compatible with MATLAB. While the full version is priced comparable to MATLAB,

the free version (Sysquake LE) is more than powerful enough to do some serious

work while remaining quite code compatible with MATLAB.

The website is

http://www.calerga.com/products/Sysquake/index.html

A list of differences between MATLAB syntax and Sysquake is here:

http://www.calerga.com/doc/SQ3_main.htm

There's also a good table of numerical analysis software available for Mac OSX here:

http://en.wikipedia.org/wiki/Comparison_of_numerical_analysis_software

## Re: M-file editor

I've been using TextMate. Installing it's Matlab bundle takes a bit more work (comes with many other bundles as well)

http://wiki.macromates.com/Main/Bundles

The bundle doesn't presently respect Octave's number-sign comment character, but that is easily fixed.

http://www.nabble.com/Octave-Matlab-bundle-tc15537210.html

There is at least one attempt to improve the Matlab bundle, but it may break some of what is needed for Octave.

http://kjosmoen.org/2007/3/28/new-matlab-bundle-for-textmate

Ben Abbott

small deeds > BIG INTENTIONS

## Matlab Bundle for TextMate

I've just taken as moderator of the Matlab bundle for TextMate, so I'm posting here to ask for suggestions and help from anyone who's interested.

I've written a quick blog post outlining my immediate aims here, and I'm keep to get patches and suggestions from anyone who feels like helping out.

At least a few of the bits and bobs from Thomas Kjosmoen got added to the bundle a while ago, in particular the drag commands and function snippet. I've also just committed some additions and changes which make the bundle behave a bit more like the others.

My hope is that if I make my planned changes, and get enough suggestions, we can whip the bundle into something really useful for both Matlab and Octave users.

Cheers,

Matt Foster

blog.my-mili.eu

## SAGE: Open Source Mathematics Software

I also recommend SAGE: Open Source Mathematics Software.

It is free to download at "sagemath.org"

b.

## Don't forget FreeMat

I've also found FreeMat to be a good alternative (http://freemat.sf.net) for quick things or matrix-y things. If it's more complex than that, I'll use R or Igor Pro.

## GUI for Octave

Nobody has mentioned qtoctave as a viable GUI tool for octave.

## FreeMat

I think FreeMat now has a compiler. Not bad for what I think is a one-man show.

## Another nice package is

Python wtith numpy, scipy and matplotlib with ipython as the interactive shell.

Although the code is not compatible with matlab it is quite similar and you can read matlab arrays (never tried it, though).

Regards,

Markus