Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-sjtt6 Total loading time: 0 Render date: 2024-07-04T17:20:55.556Z Has data issue: false hasContentIssue false

Chapter 2 - Octave programming

Published online by Cambridge University Press:  05 June 2012

David Yevick
Affiliation:
University of Waterloo, Ontario
Get access

Summary

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. (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. (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.

Type
Chapter
Information
A Short Course in Computational Science and Engineering
C++, Java and Octave Numerical Programming with Free Software Tools
, pp. 5 - 14
Publisher: Cambridge University Press
Print publication year: 2012

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@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.

  • Octave programming
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.002
Available formats
×

Save book 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 Dropbox.

  • Octave programming
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.002
Available formats
×

Save book to Google Drive

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.

  • Octave programming
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.002
Available formats
×