First steps in Octave

by Bas Kooijman, 5 April 2002


These notes are prepared for getting started in the computer language Octave 3, which uses Gnuplot for graphics, which ia included in Octave.

This note assumes that Octave 3 is installed, and that you type the codes on Octaves' command line that are shown in magenta (while skipping the comments, of course).

General recommendations

Script files

Although Octave allows you to work directly on the command line, with handy history memory (arrow keys), it is best to work in script files as soon as you want to fit a model and display the results or do similar more complex things. A script file is a file with a name that has extension .m and does not start with the word function. After saving the script file with some editor (such as Emacs) in plain ascii, type the name of the script file on Octave's command line (without extension .m) and Octave executes the file as if all its contents was typed in on the command line.

Label all script-files well with explanatory text, including your name, date and purpose, such that it makes sense when you see it again much later.

Add enough explanations in your script files and functions. All text on a line after character % is not executed by Octave. Emacs expects %% if a whole line is explanatory text.


Type help function-name to get an explantion how a function works.

Type who or whos to get information about the variables and functions that are known at any given moment.

a = 2;