Octave is one of the major free alternatives to MATLAB, others being Scilab and FreeMat. Scilab, however, puts less emphasis on (bidirectional) syntactic compatibility with MATLAB than Octave does.
The project was conceived around 1988. At first it was intended to be a companion to a chemical reactor design course. Real development was started by John W. Eaton in 1992. The first alpha release dates back to January 4, 1993 and on February 17, 1994 version 1.0 was released. Version 4.0.0 was released on May 29, 2015.
In addition to use on desktops for personal scientific computing, Octave is used in academia and industry. For example, Octave was used on a massive parallel computer at Pittsburgh Supercomputing Center to find vulnerabilities related to guessing social security numbers.
Dramatic acceleration with OpenCL or CUDA is also possible with use of GPUs.
The Octave language is an interpreted programming language. It is a structured programming language (similar to C) and supports many common C standard library functions, and also certain UNIX system calls and functions. However, it does not support passing arguments by reference.
Typing a TAB character on the command line causes Octave to attempt to complete variable, function, and file names (similar to Bash's tab completion). Octave uses the text before the cursor as the initial portion of the name to complete.
When running interactively, Octave saves the commands typed in an internal buffer so that they can be recalled and edited.
Octave includes a limited amount of support for organizing data in structures. In this example, we see a structure "x" with elements "a", "b", and "c", (an integer, an array, and a string, respectively):
As a general rule, GNU Octave recognizes as termination of a given 'block' either the keyword 'end' (which is compatible with the MATLAB language) or a more specific keyword 'end_block'. As a consequence, an 'unwind_protect' block can be terminated either with the keyword 'end_unwind_protect' as in the example, or with the more portable keyword 'end'.
The cleanup part of the block is always executed. In case an exception is raised by the body part, cleanup is executed immediately before propagating the exception outside the block 'unwind_protect'.
GNU Octave also supports another form of exception handling (compatible with the MATLAB language):
This latter form differs from an 'unwind_protect' block in two ways. First, exception_handling is only executed when an exception is raised by body. Second, after the execution of exception_handling the exception is not propagated outside the block (unless a 'rethrow( lasterror )' statement is explicitly inserted within the exception_handling code).
Variable-length argument lists
Octave has a mechanism for handling functions that take an unspecified number of arguments without explicit upper limit. To specify a list of zero or more arguments, use the special argument varargin as the last (or only) argument in the list.
Elements can be referenced without creating a new variable by cascaded indexing, e.g. [1:10](3);
Strings can be defined with the double-quote " character as well as the single-quote ' character;
When the variable type is single (a single-precision floating-point number), Octave calculates the "mean" in the single-domain (MATLAB in double-domain) which is faster but gives less accurate results;
Blocks can also be terminated with more specific Control structure keywords, i.e., endif, endfor, endwhile, etc.;
Functions can be defined within scripts and at the Octave prompt;
Presence of a do-until loop (similar to do-while in C).
Many, but not all, of the numerous MATLAB functions are available in GNU Octave, some of them accessible through packages in Octave Forge. The functions available as part of either core Octave or Forge packages are listed online.
A list of unavailable functions is included in the Octave function __unimplemented.m__. Unimplemented functions are also listed under many Octave Forge packages in the Octave Wiki.
When an unimplemented function is called the following error message is shown:
Several 3rd-party graphical front-ends have also been developed, like ToolboX for coding education.
With Octave code, the user can create GUI applications . Here are some examples.
Button, edit control, checkbox
% create figure and panel on itf=figure;% create a button (default style)b1=uicontrol(f,"string","A Button","position",);% create an edit controle1=uicontrol(f,"style","edit","string","editable text","position",);% create a checkboxc1=uicontrol(f,"style","checkbox","string","a checkbox","position",);
% create figure and panel on itf=figure;% create a button groupgp=uibuttongroup(f,"Position",[00.511])% create a buttons in the groupb1=uicontrol(gp,"style","radiobutton","string","Choice 1","Position",);b2=uicontrol(gp,"style","radiobutton","string","Choice 2","Position",);% create a button not in the groupb3=uicontrol(f,"style","radiobutton","string","Not in the group","Position",);
An advanced example of Octave GUI application composition can be seen in the FEATool Multiphysics FEM simulation toolbox.
Octave also has packages available for free. Those packages are located at Octave-Forge . Available packages are:
^Megrey, Bernard A.; Moksness, Erlend (2008). Computers in Fisheries Research. Springer Science & Business Media. p. 345. ISBN978-1-4020-8636-6.
^Kapuno, Raul Raymond (2008). Programming for Chemical Engineers Using C, C++, and MATLAB. Jones & Bartlett Publishers. p. 365. ISBN978-1-934015-09-4.
^Herman, Russell L. (2013). A Course in Mathematical Methods for Physicists. CRC Press. p. 42. ISBN978-1-4665-8467-9.
^Wouwer, Alain Vande; Saucez, Philippe; Vilas, Carlos (2014). Simulation of ODE/PDE Models with MATLAB, Octave and Scilab: Scientific and Engineering Applications. Springer. pp. 114-115. ISBN978-3-319-06790-2.