Primary Menu

Octave

The PC Lab in PSB 208 has the computer software Octave installed. Octave is
a clone of the popular mathematical software system MatLab. The MatLab system
is also available in our computer lab and there is a
student version
available on the web for a moderate fee. The MatLab system is used in many
engineering and scientific computing laboratories. Octave is a free system
available online by one of the creators of MatLab at the University of
Wisconsin. It is licensed under the General Public
License or GPL (see Wikipedia
for more information). Its abilities include matrix computations, linear
algebra,
plotting and structured programming.

When used as a programming tool the program code is edited in an external
editor supplied with the system and then programs are run by entering commands
in the Octave command window. With a little care it is possible to use
core elements of the MatLab/Octave programming language so that the program code
will work with either system.

Installing Octave On Your Computer

Either save it to a temporary location and then execute it
or else execute the program immediately during the download process.

Note: I recommend choosing the non-Java version during the installation since it seems to be more stable.

2) The program will be installed in your C: drive and there will be
startup folder containing a startup icon and PDF file version of the
manual. The startup folder can be opened by clicking Start/All
Programs/GNU Octave.

You start the program by clicking the startup icon and waiting for
the prompt to appear. You then can just start entering statements into Octave by typing
expressions and then clicking the enter key:

That last command "exit" will close the Octave window and end the program.

3) By default, Octave will look for your program code in
the folder

C:\Program Files\Octave

You want to create a better location for your files. A good solution is
to create a folder "Octave Programs" in your "My Documents" folder. Next
you need to make this folder the current working
directory in Octave. This can be done at startup by using the change directory
command cd as follows for Windows XP:

The best method is to have the system automatically make this change for you by
editing the properties of the desktop startup icon. To do this right
click the startup icon, click "Properties" and then edit the "Start In:"
folder to be your code folder.

The next time you start Octave the working directory will be the one
you entered in the "Start In:" field. You can check whether this is the case by
using the pwd command as above.

4) The default text editor for writing octave code is the SciTE program and you can copy a startup link to your desktop also.
It is located at

C:\Program Files\GNU Octave 3.0.1\tools\wscite\SciTE.exe

This last step may not be necessary since the Windows
system will associate this editor with text file with the m-extension.
Thus, if you create an empty plain text file in your code folder (Step 2)
with the name test.m then double
clicking this file icon will open the editor. At that point you can use
the File/Save As option to rename it.

5) To test your system create the file test.m in Step 4 and enter the single statement:

disp('Hello World!')

and then Save
your changes. Next double-click the Octave startup on your desktop and
enter the statement 'test' followed by the Enter key. Here's what should
happen:

octave:1> test
Hello World!
octave:2>

Alternately, you can just enter statements directly
into Octave by typing say:

The preferred method of writing code is to use a source
file (as above) and then test the code in Octave. When something is not
right you should modify the source file, save the changes and repeat the
testing step. Nevertheless, any code statement can be entered directly
into Octave for testing purposes or for doing very simple examples.

6) To get started with programming read over the
introductory material in the Octave Manual starting at page 33. Another
way to get started is to skim over the MatLab Getting Started Manual
starting with Chap 3 and Chap 5. The Matlab system has a completely
different interface than Octave but the MatLab Command window is very
similar to the Octave system language:

Octave and MatLab are quite compatible and with a little
care one can write programs that will simultaneously work with either
system. In addition, MatLab has an extensive website to help you learn
their programming language, see

7) It is possible to paste code into the command line and to
copy portions of the command window for use in text files. Here's how
you do that:

Enlarge the octave window so that all computations are
showing.

Right-click in the top window strip to reveal the edit menu.
Choose Edit and select Mark.

With your mouse select button held down select the portion of
the window you want to copy. It should highlight as you move your
mouse. When the material is selected press the Enter-key. The
selection is now on the clipboard and can be pasted into a text
editor.

The reverse process of pasting a command into Octave is done by first
copying the command to the clipboard from a file or web page. Then, in
the octave window right-click the top window strip and select Edit then
Paste.