A short introduction to Octave

Download as a PDF

Introduction

I've noticed that a lot of people wanted to do some of there maths work at home, either for some extra practice or work on assignments. Unfortunately MATLAB is a commercial product and the University is unable to hand out copies to students for free.

Fortunately there's a very nice piece of Open Source Software out there called Octave, which allows you to do mostly everything you could wish to do - without needing to fork out a penny.

The set-up we wish to use is actually a combination of three separate pieces of software:

Fortunately for us there's a very friendly installer available for Windows which contains all three of these packages, and this is what we're going to use.

Note: One issue to note is that this installer is not designed to be used along side Cygwin. (It will really stuff up your Cygwin set-up.) In that case it is better to use Cygwin's installer to install Octave from the Maths category, and run Octave through Cygwin.

Installation

This guide was done using octave-2.1.73-1 the latest version as of the 24/4/06.
  1. First up, zip over to the Octave Forge download page. (http://sourceforge.net/project/showfiles.php?group_id=2888). We're looking for octave-forge-windows. Click on the green download button and select the latest file for download.
  2. Once you've downloaded the file to some place that is convent, double click the file to start the installation process.
  3. Installation is pretty painless. Just select a language, whether you want icons in the start menu or desktop and the location to install Octave to.
  4. Once the installation is finished you can start Octave by going to Start > Programs > GNU Octave 2.1.73 > GNU Octave 2.1.73.
  5. And there you're done!

Using Octave

One of the first things you'll probably notice about Octave is that it doesn't have a nice flashy GUI like MATLAB. Lucky for us, this isn't too much of a problem for we're far more interested in being able to solve problems than looking at a GUI.

Most of the basic syntax is exactly the same between Octave and MATLAB. For example, to enter a simple matrix and store it in the variable A we just type:

A = [1 2 3 4; 5 6 7 8; 9 10 11 12]

and then press enter.

octave:1> A = [1 2 3 4; 5 6 7 8; 9 10 11 12]
A =

1 2 3 4
5 6 7 8
9 10 11 12

Once you're finished you can close Octave by either clicking on the X button or typing exit at the prompt.

There's also a really comprehensive manual included which features a very handy 'A Brief Introduction to Octave', which shows you how to at least get the most basic tasks done in Octave. But once again, if you know the syntax for doing something in MATLAB, it's most likely very similar or even the same in Octave.

Adding extra scripts

One point of particular interest is the ability to using additional scripts that have been written by yourself or others. (For example, the Maths B functions like rrefmod2, ass_2RSA, encodeornot, etc.) The easiest way to add these functions is to place them in a folder in the usr\share\octave\site\m\ folder under the location you installed Octave to.

For example, under the default install location you could put a folder called myscripts in C:\Program Files\GNU Octave 2.1.73\usr\share\octave\site\m\. Then any functions in this folder can be used while in Octave.