Tools/Octave Matlab
|
MATLABis a numerical computing environment and programming language developed by MathWorks. GNU Octave is a free software under the terms of the GNU General Public License (GPL) using a language that is mostly compatible with MATLAB.
Syntax differences
In general the MATLAB syntax is stricter than Octave. Therefore it is recommended to use the MATLAB syntax for compatibility. The most notable restrictions in MATLAB compared to Octave are:
Type | Octave | MATLAB |
---|---|---|
String delimiters | ' or " | only ' |
Ends | can use end{if,for,...} | only end |
Comment | # or % | only % |
Hexadecimal | supports 0xF0 | needs hex2dec('F0') |
Autoincrement and Assign | supports i++; ++i; i+=1; etc. | no support |
Logical Operator NOT | ! or ~ | only ~ (as used in: Not Equal: ~=) |
a full list of differences is maintained in the MATLAB Programming Wikibook.
Octave
Installation
Octave is mainly built for Linux and is therefore packaged for many distributions, but it can also be installed on OS X and Windows. To test your installation in a quick and easy manner you could try to print a sinusoidal wave:
t = linspace(0, 10, 100); plot(t, sin(t));
Windows
There is full page at the Octave wiki about how to install Octave on Windows with different installers, compilers and versions. After trying some of the variants, we found out that the easiest way is to download the latest version for MinGW at Sourceforge (current version of writing this article: 3.6.2) or from guo's Software Server. There are two compressed files, one with Octave itself and one with various useful packages (alphabetical list of all functions). We recommend to install the packages also. Simply uncompress the files and follow the instructions in the readme files.