Tools/Octave Matlab
m |
|||
(6 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | |||
{{TOC right}} | {{TOC right}} | ||
[http://www.mathworks.ch/products/matlab/index.html MATLAB]is a numerical computing environment and programming language developed by [http://www.mathworks.ch/index.html MathWorks]. [http://www.gnu.org/software/octave/ GNU Octave] is a free software under the terms of the [https://en.wikipedia.org/wiki/GNU_General_Public_License GNU General Public License] (GPL) using a language that is mostly compatible with MATLAB. | [http://www.mathworks.ch/products/matlab/index.html MATLAB]is a numerical computing environment and programming language developed by [http://www.mathworks.ch/index.html MathWorks]. [http://www.gnu.org/software/octave/ GNU Octave] is a free software under the terms of the [https://en.wikipedia.org/wiki/GNU_General_Public_License GNU General Public License] (GPL) using a language that is mostly compatible with MATLAB. | ||
= Syntax differences = | = Syntax differences = | ||
− | In general | + | 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: |
{|class=wikitable | {|class=wikitable | ||
|- | |- | ||
! Type || Octave || MATLAB | ! Type || Octave || MATLAB | ||
|- | |- | ||
− | | String delimiters || ' or " || only ' | + | | String delimiters || ' or " || only '''''' |
|- | |- | ||
− | | Ends || can use ''end{if,for,...}'' || only ''end'' | + | | Ends || can use ''end{if,for,...}'' || only '''end''' |
|- | |- | ||
− | | Comment || # or % || only % | + | | Comment || # or % || only '''%''' |
|- | |- | ||
− | | Hexadecimal || supports ''0xF0'' || needs ''hex2dec('F0')'' | + | | Hexadecimal || supports ''0xF0'' || needs '''hex2dec('F0')''' |
|- | |- | ||
− | | Autoincrement and Assign || supports ''i++; ++i; i+=1; etc.'' || no support | + | | Autoincrement and Assign || supports ''i++; ++i; i+=1; etc.'' || '''no support''' |
+ | |- | ||
+ | | Logical Operator NOT || ! or ~ || only '''~''' (as used in: Not Equal: ~=) | ||
|- | |- | ||
|} | |} | ||
Line 25: | Line 26: | ||
== Installation == | == Installation == | ||
− | Octave is mainly built for Linux and is therefore [http://wiki.octave.org/Octave_for_GNU/Linux packaged for many distributions], but it can also be installed on [http://wiki.octave.org/Octave_for_MacOS_X OS X] and [http://wiki.octave.org/Octave_for_Windows Windows]. To test your installation in quick and easy manner you could try to print a sinusoidal | + | Octave is mainly built for Linux and is therefore [http://wiki.octave.org/Octave_for_GNU/Linux packaged for many distributions], but it can also be installed on [http://wiki.octave.org/Octave_for_MacOS_X OS X] and [http://wiki.octave.org/Octave_for_Windows Windows]. To test your installation in a quick and easy manner you could try to print a sinusoidal wave: |
t = linspace(0, 10, 100); | t = linspace(0, 10, 100); | ||
plot(t, sin(t)); | plot(t, sin(t)); | ||
=== Windows === | === Windows === | ||
− | There is full page at the [http://wiki.octave.org/Main_Page Octave wiki] about how to [http://wiki.octave.org/Octave_for_Windows 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 [http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/ Sourceforge] ([http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.2%20for%20Windows%20MinGW%20installer/ current version of writing this article: 3.6.2]) or from [[User: | + | There is full page at the [http://wiki.octave.org/Main_Page Octave wiki] about how to [http://wiki.octave.org/Octave_for_Windows 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 [http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/ Sourceforge] ([http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.2%20for%20Windows%20MinGW%20installer/ current version of writing this article: 3.6.2]) or from [[User:oliver.gubler|guo]]'s [ftp://fpga:fpga@153.109.5.248 Software Server]. There are two compressed files, one with Octave itself and one with various useful packages ([http://octave.sourceforge.net/functions_by_alpha.php alphabetical list of all functions]). We recommend to install the packages also. Simply uncompress the files and follow the instructions in the ''readme'' files. |
Latest revision as of 16:18, 24 April 2015
|
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.