Published online by Cambridge University Press: 05 June 2012
For small programs or rapid prototyping of ideas and methods, the commercial MATLAB® language, or its freeware alternatives, offers a practical alternative to C++ or FORTRAN. In this book, the free GNU Octave implementation is discussed from a scientific programming perspective. After becoming familiar with the central language constructs summarized below, the built-in Octave help facilities conveniently provide information on specialized, infrequent commands.
Obtaining octave
The Windows and Mac installation packages for GNU Octave are currently located at octave.sourceforge.net. Linux versions are available at the main Octave web site www.gnu.org/software/octave. When the program is installed, a variety of additional packages and the creation of a database of C++ components accessible by the editor can be selected. Unless space is an issue, these options should be chosen.
Command summary
(1) Running Octave. After clicking on the Octave icon, statements are entered interactively by typing into the resulting command window at the > prompt. An Octave session is terminated by typing quit.
(2) System commands. To change from the startup directory (folder) to the directory that either contains or will contain program files, type cd X:\dir1\dir2\ . . . \programDirectory, where X is the partition (logical drive) containing the desired directory and \dir1\dir2 . . . \programDirectory is an ordered sequence of the names of the directories enclosing the directory, \programDirectory, in which the program is located. If one or more directory names contain spaces, the entire expression containing these names must be surrounded by double apostrophes ("), e.g. cd "X:\My Documents". Representative operating-system commands that can be issued from the Octave prompt include mkdir directoryName, which creates the directory directoryName, rmdir directoryName, which removes this directory, dir or Is which display the contents of a directory, .., which moves to one directory higher in the directory tree, ., which represents the current directory, rename file1.1 file2.2, which renames the file file1.1 to the name file2.2, and copy, which similarly copies a file.
…
To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.