1,848
edits
Carandraug (talk | contribs) (→How can I cite Octave?: update and expand section) |
(Update some outdated links.) |
||
(38 intermediate revisions by 17 users not shown) | |||
Line 1: | Line 1: | ||
This is a list of frequently asked questions (FAQ) for GNU Octave users. | This is a list of frequently asked questions (FAQ) for GNU Octave users. | ||
We are always looking for new questions (with answers), better answers, or both. Feel free to edit this page with your changes. If you have general questions about GNU Octave, or need help for something that is not covered by the Octave manual or the FAQ, please use the [https:// | We are always looking for new questions (with answers), better answers, or both. Feel free to edit this page with your changes. If you have general questions about GNU Octave, or need help for something that is not covered by the Octave manual or the FAQ, please use the [https://lists.gnu.org/mailman/listinfo/help-octave help@octave.org mailing list]. | ||
This FAQ is intended to supplement, not replace, the GNU Octave manual. Before posting a question to the [https:// | This FAQ is intended to supplement, not replace, the GNU Octave manual ([https://www.gnu.org/software/octave/doc/interpreter/ HTML], [https://www.gnu.org/software/octave/octave.pdf PDF]). Before posting a question to the [https://lists.gnu.org/mailman/listinfo/help-octave help@octave.org mailing list], you should first check to see if the topic is covered in the manual. | ||
<div class="tocinline">__TOC__</div> | |||
=General= | =General= | ||
Line 18: | Line 20: | ||
==What is Octave-Forge?== | ==What is Octave-Forge?== | ||
[ | |||
[https://octave.sourceforge.io/ Octave-Forge] is a collection of packages for GNU Octave, something similar to the Matlab toolboxes. When talking about the two projects at the same time, GNU Octave is usually referred to as Octave core (or just ''core''). [https://octave.sourceforge.io/ Octave-Forge] also serves as a test bed for code that may eventually end up in the core, and distributes binaries for systems with a lack of developers tools (mainly Windows). | |||
==Who uses Octave?== | ==Who uses Octave?== | ||
Line 59: | Line 62: | ||
Octave is also free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation, or at your option any later version. | Octave is also free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation, or at your option any later version. | ||
== How can I cite Octave? == | == How can I cite Octave? == | ||
Line 120: | Line 117: | ||
==How can I get involved in Octave development?== | ==How can I get involved in Octave development?== | ||
Be around. Be social. Participate in the [https://mailman.cae.wisc.edu/listinfo/help-octave help] and [https://mailman.cae.wisc.edu/listinfo/octave-maintainers maintainers] mailing lists. Find things about Octave you don't like, and start thinking about how to fix them. Many people who now contribute to Octave first spent several years helping in the mailing list before they started to delve into the code. A good way to learn Octave is to understand the problems other people are having with it, so being helpful in the mailing lists not only helps Octave as a whole, but it also prepares you to be a better Octave contributor. | Be around. Be social. Participate in the [https://mailman.cae.wisc.edu/listinfo/help-octave help] | ||
and [https://mailman.cae.wisc.edu/listinfo/octave-maintainers maintainers] | |||
mailing lists. Find things about Octave you don't like, and start thinking | |||
about how to fix them. Many people who now contribute to Octave first spent | |||
several years helping in the mailing list before they started to delve into | |||
the code. A good way to learn Octave is to understand the problems other | |||
people are having with it, so being helpful in the mailing lists not only | |||
helps Octave as a whole, but it also prepares you to be a better Octave | |||
contributor. | |||
If you feel ready to dive right into the code, read [[Hacking | here]] and [http://www.gnu.org/software/octave/get-involved.html here] for guidance. | If you feel ready to dive right into the code, read [[Hacking | here]] | ||
and [http://www.gnu.org/software/octave/get-involved.html here] for | |||
guidance. But do not send an email to the mailing lists listing your | |||
skills and offering to help. We won't just suggest things for you to do. | |||
We lack volunteers and we do need your help, but because of that, we also | |||
lack the time to provide good guidance and mentoring. If there is a | |||
specific short-term project you would like to work on, say so, and just | |||
do it. Then ask for help or advice when you're doing it. It is a lot | |||
more important that you do something that you're actually interested on | |||
than something we suggested because it only matches your skills. | |||
We also need help with this wiki and the [http://www.gnu.org/software/octave/doc/interpreter/ manual]. These are also important tasks. The documentation is | We also need help with this wiki and the | ||
[http://www.gnu.org/software/octave/doc/interpreter/ manual]. These are | |||
also important tasks. The documentation is easy to patch, and the help text | |||
for individual functions even more so. Editing this wiki is even easier. | |||
Accurate bug reporting is also very useful. Find and report [http://www.gnu.org/software/octave/bugs.html bugs], making an attempt to diagnose them. Eventually, you will also know how to fix them. If you want to help with bug reports or patches, subscribe to [https://savannah.gnu.org/mail/?group=octave the bug tracker mailing list]. You'll get updates on all bug activity, and you can jump in when you see something you can help with. | Accurate bug reporting is also very useful. Find and report | ||
[http://www.gnu.org/software/octave/bugs.html bugs], making an attempt to | |||
diagnose them. Eventually, you will also know how to fix them. If you want | |||
to help with bug reports or patches, subscribe to | |||
[https://savannah.gnu.org/mail/?group=octave the bug tracker mailing list]. | |||
You'll get updates on all bug activity, and you can jump in when you see | |||
something you can help with. | |||
Look at our [[Projects]] and [[Summer of Code Project Ideas]] if you need specific inspiration for coding tasks that we would like to get done. See also the list of [[short projects]]. | Look at our [[Projects]] and [[Summer of Code Project Ideas]] if you need | ||
specific inspiration for coding tasks that we would like to get done. See | |||
also the list of [[short projects]]. | |||
=Licensing issues= | =Licensing issues= | ||
Line 168: | Line 193: | ||
=What's new in Octave= | =What's new in Octave= | ||
Each new Octave release introduces many new features. The following are | |||
a distilled list of the major changes. A complete list of user visible | |||
changes can be seen by running {{codeline|news}} at the Octave prompt, and | |||
a full list of changes is on the {{Filepath|Changelog}} distributed with | |||
the Octave sources. | |||
==Coming in a future release== | |||
See [http://hg.savannah.gnu.org/hgweb/octave/file/tip/NEWS NEWS on the development branch] | |||
==What's new in version series 4.0.X of Octave== | |||
See the complete user-visible changes on the [https://www.gnu.org/software/octave/NEWS-4.0.html NEWS file]. | |||
* First official release of the GUI. | |||
* Release of official windows binaries. | |||
* Experimental support for [[classdef]]. | |||
* OpenGL graphics with Qt widgets. | |||
* Several functions for reading, writing, and recording of audio. | |||
==What's new in version series 3.8.X of Octave== | |||
See the complete user-visible changes on the [https://www.gnu.org/software/octave/NEWS-3.8.html NEWS file]. | |||
* Experimental GUI interface. | |||
* OpenGL graphics with fltk widgets. | |||
* Support for nested functions. | |||
* Support for java packages in Octave core. | |||
* Reading and writing of image files vastly extended. | |||
==What's new in version series 3.6.X of Octave== | |||
See the complete user-visible changes on the [https://www.gnu.org/software/octave/NEWS-3.6.html NEWS file]. | |||
* Perl compatible regular expressions | * Perl compatible regular expressions | ||
* A profiler has been added. | * A profiler has been added. | ||
* Broadcasting enabled for all built-in binary element-wise operators. | * Broadcasting enabled for all built-in binary element-wise operators. | ||
* Performance of all m-file string functions has been improved. | * Performance of all m-file string functions has been improved. | ||
== | ==What's new in version series 3.4.X of Octave== | ||
See the complete user-visible changes on the [https://www.gnu.org/software/octave/NEWS-3.4.html NEWS file]. | |||
* Many improvements to native OpenGL plotting | * Many improvements to native OpenGL plotting | ||
* ARPACK now distributed with Octave | * ARPACK now distributed with Octave | ||
* Indexing optimisations | * Indexing optimisations | ||
* FTP | * FTP objects | ||
* Function handles aware of overloaded functions | * Function handles aware of overloaded functions | ||
* bsxfun optimised for basic arithmetic functions | * bsxfun optimised for basic arithmetic functions | ||
* Matlab-style ignoring of output arguments using {{Codeline|~}} | * Matlab-style ignoring of output arguments using {{Codeline|~}} | ||
* Many optimisations of the accumarray function | * Many optimisations of the accumarray function | ||
* Sparse matrix indexing has been rewritten for speed | * Sparse matrix indexing has been rewritten for speed | ||
* The pkg command now accepts a -forge option to pull packages directly from Octave-forge | * The pkg command now accepts a -forge option to pull packages directly from Octave-forge | ||
== | ==What's new in version series 3.2.X of Octave== | ||
See the complete user-visible changes on the [https://www.gnu.org/software/octave/NEWS-3.2.html NEWS file]. | |||
* | |||
* | * Single precision type | ||
* | * Experimental OpenGL graphics toolkit to replace gnuplot | ||
* Object orient programming via @class named directories | |||
* 64-bit compilation support | * 64-bit compilation support | ||
* gzipped files and stream and consequently support of Matlab v7 files | * gzipped files and stream and consequently support of Matlab v7 files | ||
* a fully compatible MEX interface | * a fully compatible MEX interface | ||
* imwrite and imread (based on the GraphicsMagick library) | * imwrite and imread (based on the GraphicsMagick library) | ||
* Lazy transpose <br/> Special treatment in the parser of things like "a' * b", where the transpose is never explicitly formed but a flag is rather passed to the underlying LAPACK code. | * Lazy transpose <br/> Special treatment in the parser of things like "a' * b", where the transpose is never explicitly formed but a flag is rather passed to the underlying LAPACK code. | ||
== | == Older releases == | ||
For full details on older releases, see: | |||
* [http://hg.savannah.gnu.org/hgweb/octave/file/83792dd9bcc1/etc/NEWS.1 NEWS.1] for the 1.X.Y series | |||
* [http://hg.savannah.gnu.org/hgweb/octave/file/83792dd9bcc1/etc/NEWS.2 NEWS.2] for the 2.X.Y series | |||
* [http://hg.savannah.gnu.org/hgweb/octave/file/83792dd9bcc1/etc/NEWS.3 NEWS.3] for the 3.X.Y series | |||
=What documentation exists for Octave?= | =What documentation exists for Octave?= | ||
Line 274: | Line 309: | ||
* http://www.octave.org/download.html | * http://www.octave.org/download.html | ||
* | * https://ftp.gnu.org/gnu/octave/ | ||
Since Octave is distributed under the terms of the GPL, you can get Octave from a friend who has a copy, or from the Octave website. | Since Octave is distributed under the terms of the GPL, you can get Octave from a friend who has a copy, or from the Octave website. | ||
==Pre-compiled | ==Pre-compiled binaries == | ||
:''See also: [[Build from source]]'' | |||
The Octave project does not distribute | The Octave project does not normally distribute its own binaries, but other projects do. | ||
For example, Linux and BSD distributions provide by their respective Octave binaries. | |||
Windows is a recent exception, in that binaries are available directly from the Octave project (starting from version 4.0). | |||
For an up-to-date listing, see: | |||
* http://www.octave.org/download.html | * http://www.octave.org/download.html | ||
As of today, Octave binaries are available at least on Debian, Ubuntu, RedHat, Suse and Fedora GNU/Linux | As of today, Octave binaries are available at least on Debian, Ubuntu, RedHat, Suse, and Fedora GNU/Linux; Mac OS X; and Windows (versions 98, 2000, XP, Vista, 7, 8, and 10). | ||
==How do I get a copy of Octave for (some other platform)?== | ==How do I get a copy of Octave for (some other platform)?== | ||
Line 294: | Line 332: | ||
There is an unofficial Octave app available for Android in the Google Play store. Please see [[Android]] for more information. | There is an unofficial Octave app available for Android in the Google Play store. Please see [[Android]] for more information. | ||
This version of Octave is no longer freely available and has become 'nagware'. This is a sad turn of events. | |||
=Installation issues and problems= | =Installation issues and problems= | ||
Line 311: | Line 351: | ||
Yes, but development is done primarily with GCC, so you may hit some incompatibilities. Octave is intended to be portable to any standard conforming compiler. If you have difficulties that you think are bugs, please report them to the http://bugs.octave.org bug tracker, or ask for help on the [mailto:help@octave.org mailing list]. | Yes, but development is done primarily with GCC, so you may hit some incompatibilities. Octave is intended to be portable to any standard conforming compiler. If you have difficulties that you think are bugs, please report them to the http://bugs.octave.org bug tracker, or ask for help on the [mailto:help@octave.org mailing list]. | ||
== How do | == How do install or load all Octave packages? == | ||
Do not do it! Really, there is no reason to do this. Octave | |||
Do not do it! Really, there is no reason to do this. Octave has many | |||
packages for different needs and is unlikely that you need all of | |||
them. You either have a small set of required packages, in which case | |||
you know them by name; or you want them all "just because", in which case | |||
you don't really need them. | |||
The common misconception is that the more packages one has installed | |||
and loaded, the more complete and powerful its Octave installation will be. | |||
However, in the same way one would never install all perl modules, | |||
ruby gems, python packages, and C++ libraries (because it simply makes | |||
no sense), one should not install all Octave packages. | |||
Packages should be installed and loaded selectively. Note that some | |||
packages are meant to shadow core functions changing the way Octave works, | |||
and that different packages can have different functions with the same name | |||
leading to unpredictable results. | |||
If you really really really want to do load all packages, you can with | |||
the following: | |||
## WARNING: loading all packages is probably not the solution you are looking for. | |||
cellfun (@(x) pkg ("load", x.name), pkg ("list")); | |||
== How do I automatically load a package at Octave startup? == | |||
When Octave starts, it runs {{Path|~/.octaverc}}. If you want Octave to | |||
automatically load a package, simply add a {{codeline|pkg load pkg-name}} | |||
command to it. If the files does not exist, create it. | |||
If you do this, remember that other people may not have Octave configured | |||
to load packages at startup. Therefore, if you write code for others, | |||
remember that your programs still need to load the packages they require. | |||
=Coding= | =Coding= | ||
Line 335: | Line 406: | ||
As a natural extension of this, functions can also be defined in script files (m-files whose first non-comment line isn't {{Codeline|function out = foo (...)}}) | As a natural extension of this, functions can also be defined in script files (m-files whose first non-comment line isn't {{Codeline|function out = foo (...)}}) | ||
Note: MATLAB R2016b added the ability to [http://www.mathworks.com/help/matlab/matlab_prog/local-functions-in-scripts.html define functions in script files]. | |||
===Comments with #=== | ===Comments with #=== | ||
Line 413: | Line 486: | ||
x += 1; | x += 1; | ||
until (x == 10) | until (x == 10) | ||
===Broadcasting=== | |||
Borrowed from [http://stackoverflow.com/q/26948776/3565696 other languages], [http://www.gnu.org/software/octave/doc/v4.0.1/Broadcasting.html octave broadcasting] allows easy and readable vectorization. | |||
f = (1:0.1:2); | |||
# put angular frequencies on the first dimension to prepare broadcasting | |||
omega = 2 * pi * f(:); | |||
# time is already on the second dimension (row vector) | |||
t = 0:0.02:2; | |||
# the resulting s will be a 2-dimensional array | |||
s = sin(omega .* t); | |||
# which can be displayed as | |||
pcolor(t, f, s) | |||
xlabel("t (s)") | |||
ylabel("f (Hz)") | |||
Note: [https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html Automatic expansion of dimensions] was added to MATLAB R2016b. | |||
==How does Octave solve linear systems?== | ==How does Octave solve linear systems?== | ||
Line 553: | Line 644: | ||
would produce value 9999999999999990000, which is close to the maximum possible value for the uint64 type, but can't be at the moment input directly, doing uint64(9999999999999990000), due to the mentioned error of rounding. | would produce value 9999999999999990000, which is close to the maximum possible value for the uint64 type, but can't be at the moment input directly, doing uint64(9999999999999990000), due to the mentioned error of rounding. | ||
Alternatively, one may use arbitrary precision arithmetic, which has as much precision as is practical to hold in your computer's memory. The ''symbolic'' package | Alternatively, one may use arbitrary precision arithmetic, which has as much precision as is practical to hold in your computer's memory. The ''symbolic'' package has a vpa() function for arbitrary precision arithmetic. Note that arbitrary precision arithmetic must be implemented '''in software''' which makes it much slower than hardware floats. | ||
Consider carefully if your problem really needs more precision. Often if you're running out of precision the problem lies fundamentally in your methods being [http://en.wikipedia.org/wiki/Numerical_stability numerically unstable], so more precision will not help you here. If you absolutely must use arbitrary-precision arithmetic, you're at present better off using a CAS instead of Octave. An example of such a CAS is [http://sagemath.org Sage]. | |||
==How do I run a Matlab P-file in Octave?== | |||
You can't. Matlab P-files (files with a .p file extension), also known as P-code, are [https://en.wikipedia.org/wiki/Obfuscation_%28software%29 obfuscated] files than cannot be run outside of Matlab itself. The original source Matlab m-files that were used to generate the P-files should be used in Octave instead. | |||
There are no plans to support running P-files produced by Matlab in Octave. | |||
=Common problems= | =Common problems= | ||
Line 574: | Line 669: | ||
==How do I get sound input or output in Windows?== | ==How do I get sound input or output in Windows?== | ||
Sound | Sound input from a sound card and output to a sound card is fully supported in Octave 4.0.0 and newer in all operating systems. Older versions of Octave had very limited audio support that was essentially Linux-specific. If you have problems with the audio I/O functions using Octave 4.0 or a newer version, please report them on the [http://bugs.octave.org bug tracker]. | ||
==I cannot install a package. Octave complains about a missing mkoctfile.== | ==I cannot install a package. Octave complains about a missing mkoctfile.== | ||
Line 600: | Line 695: | ||
Floating point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers. Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333 is only a rough approximation to 1/3), you cannot represent some fractions like <math>1/10</math> exactly in base 2. In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal). Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero. | Floating point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers. Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333 is only a rough approximation to 1/3), you cannot represent some fractions like <math>1/10</math> exactly in base 2. In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal). Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero. | ||
This isn't an Octave bug. It happens with any program that uses [http://en.wikipedia.org/wiki/IEEE_754 IEEE 754 floating point arithmetic]. The reason why Octave and other programs use IEEE 754 floats is that they are ''fast'', because they are implemented in hardware. Unless you are using very exotic hardware, Octave will use your computer's processor for floating point arithmetic. | In addition, some advanced operations are computed by approximation and are not guaranteed to be accurate, see [https://en.wikipedia.org/wiki/Rounding#Table-maker.27s_dilemma Table-maker's dilemma]. Their results are system-dependent. | ||
This isn't an Octave bug. It happens with any program that uses [http://en.wikipedia.org/wiki/IEEE_754 IEEE 754 floating point arithmetic]. To be fair, IEEE 754 also specifies decimal floating point arithmetic, which has never seen wide adoption. The reason why Octave and other programs use IEEE 754 binary floats is that they are ''fast'', because they are implemented in hardware or system libraries. Unless you are using very exotic hardware, Octave will use your computer's processor for basic floating point arithmetic. | |||
Like death and taxes, rounding errors are a fact of life. You cannot avoid them. You can only move a rounding error from one part of a computation to another, or you can use more precision and delay the rounding error. One way to delay the rounding error is to use arbitrary precision arithmetic, which is inevitably slower as it has to be implemented in software instead of hardware. You may use the vpa function from the symbolic package for this purpose. | Like death and taxes, rounding errors are a fact of life. You cannot avoid them. You can only move a rounding error from one part of a computation to another, or you can use more precision and delay the rounding error. One way to delay the rounding error is to use arbitrary precision arithmetic, which is inevitably slower as it has to be implemented in software instead of hardware. You may use the vpa function from the symbolic package for this purpose. | ||
Line 610: | Line 707: | ||
== I have installed a package but still get a "foo undefined" error == | == I have installed a package but still get a "foo undefined" error == | ||
You have probably forgotten to load the package. Use {{Codeline|pkg load package-name}} to load it. Most packages are no longer loaded automatically to avoid surprises. See reasoning on related FAQ [[FAQ#How_do_I_install_all_Octave_packages.3F|how do I install all Octave packages]]. If you want a specific package to be loaded by default at startup, consider adding the {{Codeline|pkg load}} command on your {{path|.octaverc}} file. | You have probably forgotten to load the package. Use {{Codeline|pkg load package-name}} to load it. Most packages are no longer loaded automatically to avoid surprises. See reasoning on related FAQ [[FAQ#How_do_I_install_all_Octave_packages.3F|how do I install all Octave packages]]. If you want a specific package to be loaded by default at startup, consider adding the {{Codeline|pkg load}} command on your {{path|[[.octaverc]]}} file. | ||
== Missing lines when printing under Windows with OpenGL toolkit and Intel integrated GPU == | == Missing lines when printing under Windows with OpenGL toolkit and Intel integrated GPU == | ||
Line 620: | Line 717: | ||
See also https://www.opengl.org/wiki/FAQ#Why_is_my_GL_version_only_1.4_or_lower.3F | See also https://www.opengl.org/wiki/FAQ#Why_is_my_GL_version_only_1.4_or_lower.3F | ||
= | == Plot hangs and makes the GUI unresponsive == | ||
If the Qt graphics toolkit is used and "plot" is used for the first time, the fontconfig scanner searches the font directory to build a font cache. This can take up to 3min on slow CPUs. See {{bug|45458}} | |||
= Differences between Octave and Matlab = | |||
People often ask | People often ask | ||
Line 642: | Line 743: | ||
You should also look at the pages http://octave.sourceforge.net/packages.php and http://octave.sourceforge.net/docs.html that have a function reference that is up to date. You can use this function reference to see the number of octave functions that are available and their Matlab compatibility. | You should also look at the pages http://octave.sourceforge.net/packages.php and http://octave.sourceforge.net/docs.html that have a function reference that is up to date. You can use this function reference to see the number of octave functions that are available and their Matlab compatibility. | ||
== Nested Functions == | |||
Octave has limited support for nested functions. That is | Octave has limited support for nested functions. That is | ||
Line 669: | Line 766: | ||
The authors of Octave consider the nested function scoping rules of Matlab to be more problems than they are worth as they introduce difficult to find bugs as inadvertently modifying a variable in a nested function that is also used in the parent is particularly easy for those not attentive to detail. | The authors of Octave consider the nested function scoping rules of Matlab to be more problems than they are worth as they introduce difficult to find bugs as inadvertently modifying a variable in a nested function that is also used in the parent is particularly easy for those not attentive to detail. | ||
== Differences in core syntax == | |||
There are a few core Matlab syntaxes that are not accepted by Octave, these being | There are a few core Matlab syntaxes that are not accepted by Octave, these being | ||
Line 679: | Line 776: | ||
* Matlab classdef object oriented programming is not yet supported, though work is underway in a branch of the development tree. | * Matlab classdef object oriented programming is not yet supported, though work is underway in a branch of the development tree. | ||
== Differences in core functions == | |||
A large number of the Matlab core functions (ie those that are in the core and not a toolbox) are implemented, and certainly all of the commonly used ones. There are a few functions that aren't implemented, usually to do with specific missing Octave functionality (GUI, DLL, Java, ActiveX, DDE, web, and serial functions). Some of the core functions have limitations that aren't in the Matlab version. For example the sprandn function can not force a particular condition number for the matrix like Matlab can. | A large number of the Matlab core functions (ie those that are in the core and not a toolbox) are implemented, and certainly all of the commonly used ones. There are a few functions that aren't implemented, usually to do with specific missing Octave functionality (GUI, DLL, Java, ActiveX, DDE, web, and serial functions). Some of the core functions have limitations that aren't in the Matlab version. For example the sprandn function can not force a particular condition number for the matrix like Matlab can. Another example is that testing and the runtests function work differently in Matlab and Octave. | ||
== Just-In-Time compiler == | |||
Matlab includes a "Just-In-Time" compiler. This compiler allows the acceleration of for-loops in Matlab to almost native performance with certain restrictions. The JIT must know the return type of all functions called in the loops and so you can't include user functions in the loop of JIT optimized loops. Octave doesn't have a JIT and so to some might seem slower than Matlab. For this reason you must vectorize your code as much as possible. The MathWorks themselves have a good document discussing vectorization at http://www.mathworks.com/support/tech-notes/1100/1109.html. | Matlab includes a "Just-In-Time" compiler. This compiler allows the acceleration of for-loops in Matlab to almost native performance with certain restrictions. The JIT must know the return type of all functions called in the loops and so you can't include user functions in the loop of JIT optimized loops. Octave doesn't have a JIT and so to some might seem slower than Matlab. For this reason you must vectorize your code as much as possible. The MathWorks themselves have a good document discussing vectorization at http://www.mathworks.com/support/tech-notes/1100/1109.html. | ||
== Compiler == | |||
On a related point, there is no Octave compiler, and so you can't convert your Octave code into a binary for additional speed or distribution. There have been several aborted attempts at creating an Octave compiler. Should the JIT compiler above ever be implemented, an Octave compiler should be more feasible. | On a related point, there is no Octave compiler, and so you can't convert your Octave code into a binary for additional speed or distribution. There have been several aborted attempts at creating an Octave compiler. Should the JIT compiler above ever be implemented, an Octave compiler should be more feasible. | ||
== Graphic handles == | |||
Up to Octave 2.9.9 there was no support for graphic handles in Octave itself. In the 3.2.N versions of Octave and beyond the support for graphics handles is converging towards full compatibility. The patch function is currently limited to 2-D patches, due to an underlying limitation in gnuplot, but the experimental OpenGL backend is starting to see an implementation of 3-D patches. | Up to Octave 2.9.9 there was no support for graphic handles in Octave itself. In the 3.2.N versions of Octave and beyond, the support for graphics handles is converging towards full compatibility. The patch function is currently limited to 2-D patches, due to an underlying limitation in gnuplot, but the experimental OpenGL backend is starting to see an implementation of 3-D patches. | ||
== GUI functions == | |||
There are no Matlab compatible GUI functions yet. This might be an issue if you intend to exchange Octave code with Matlab users. There are a number of bindings from Octave to {{Forge|tcl-octave|Tcl/Tk}}, [http://octaviz.sourceforge.net/index.php? VTK] and {{Forge|zenity}} for example, that can be used for a GUI, but these are not Matlab compatible. Work on a Matlab compatible GUI is in an alpha stage in the QtHandles project, which may form part of a future release of Octave. | There are no Matlab compatible GUI functions yet. This might be an issue if you intend to exchange Octave code with Matlab users. There are a number of bindings from Octave to {{Forge|tcl-octave|Tcl/Tk}}, [http://octaviz.sourceforge.net/index.php? VTK] and {{Forge|zenity}} for example, that can be used for a GUI, but these are not Matlab compatible. Work on a Matlab compatible GUI is in an alpha stage in the QtHandles project, which may form part of a future release of Octave. | ||
== Simulink == | |||
Octave itself includes no Simulink support. Typically the simulink models lag research and are less flexible, so shouldn't really be used in a research environment. However, some Matlab users that try to use Octave complain about this lack. | Octave itself includes no Simulink support. Typically the simulink models lag research and are less flexible, so shouldn't really be used in a research environment. However, some Matlab users that try to use Octave complain about this lack. | ||
== MEX-Files == | |||
Octave includes an API to the Matlab MEX interface. However, as MEX is an API to the internals of Matlab and the internals of Octave differ from Matlab, there is necessarily a manipulation of the data to convert from a MEX interface to the Octave equivalent. This is notable for all complex matrices, where Matlab stores complex arrays as real and imaginary parts, whereas Octave respects the C99/C++ standards of co-locating the real/imag parts in memory. Also due to the way Matlab allows access to the arrays passed through a pointer, the MEX interface might require copies of arrays (even non complex ones). | Octave includes an API to the Matlab MEX interface. However, as MEX is an API to the internals of Matlab and the internals of Octave differ from Matlab, there is necessarily a manipulation of the data to convert from a MEX interface to the Octave equivalent. This is notable for all complex matrices, where Matlab stores complex arrays as real and imaginary parts, whereas Octave respects the C99/C++ standards of co-locating the real/imag parts in memory. Also due to the way Matlab allows access to the arrays passed through a pointer, the MEX interface might require copies of arrays (even non complex ones). | ||
== Block comments == | |||
Block comments denoted by {{Codeline|#{}} and {{Codeline|#}}} markers (or {{Codeline|%{}} and {{Codeline|%}}}) are supported by Octave with some limitations. The major limitation is that block comments are not supported within [] or {}. | Block comments denoted by {{Codeline|#{}} and {{Codeline|#}}} markers (or {{Codeline|%{}} and {{Codeline|%}}}) are supported by Octave with some limitations. The major limitation is that block comments are not supported within [] or {}. | ||
== Mat-File format == | |||
There are some differences in the mat v5 file format accepted by Octave. Matlab recently introduced the "-V7.3" save option which is an HDF5 format which is particularly useful for 64-bit platforms where the standard Matlab format can not correctly save variables. Octave accepts HDF5 files, but is not yet compatible with the "-v7.3" versions produced by Matlab. | There are some differences in the mat v5 file format accepted by Octave. Matlab recently introduced the "-V7.3" save option which is an HDF5 format which is particularly useful for 64-bit platforms where the standard Matlab format can not correctly save variables. Octave accepts HDF5 files, but is not yet compatible with the "-v7.3" versions produced by Matlab. | ||
Line 719: | Line 816: | ||
Finally, some multi-byte Unicode characters aren't yet treated in mat-files. | Finally, some multi-byte Unicode characters aren't yet treated in mat-files. | ||
== Profiler == | |||
Thanks to Daniel Kraft's 2011 Google Summer of Code project, Octave has a profiler since version 3.6.0. However, at the moment it only produces text output and has its own makeshift interface for hierarchical profiling. | Thanks to Daniel Kraft's 2011 Google Summer of Code project, Octave has a profiler since version 3.6.0. However, at the moment it only produces text output and has its own makeshift interface for hierarchical profiling. | ||
== Toolboxes == | |||
Octave is a community project and so the toolboxes that exist are donated by those interested in them through [[Octave Forge]]. These might be lacking in certain functionality relative to the Matlab toolboxes, and might not exactly duplicate the Matlab functionality or interface. | Octave is a community project and so the toolboxes that exist are donated by those interested in them through [[Octave Forge]]. These might be lacking in certain functionality relative to the Matlab toolboxes, and might not exactly duplicate the Matlab functionality or interface. | ||
== Short-circuit {{Codeline|&}} and {{Codeline||}} operators == | |||
The {{Codeline|&}} and {{Codeline||}} operators in Matlab short-circuit when included in a condition (e.g. an {{Codeline|if}} or {{Codeline|while}} statement) and not otherwise. In Octave only the {{Codeline|&&}} and {{Codeline|||}} short circuit. Note that this means that | The {{Codeline|&}} and {{Codeline||}} operators in Matlab short-circuit when included in a condition (e.g. an {{Codeline|if}} or {{Codeline|while}} statement) and not otherwise. In Octave only the {{Codeline|&&}} and {{Codeline|||}} short circuit. Note that this means that | ||
Line 777: | Line 874: | ||
because, despite the name, the {{Codeline|all}} is really returning true if none of the elements of the matrix are zero, and since there are no elements, well, none of them are zero. This is an example of [http://en.wikipedia.org/wiki/Vacuous_truth vacuous truth]. But, somewhere along the line, someone decided that {{Codeline|if ([])}} should be false. Mathworks probably thought it just looks wrong to have {{Codeline|[]}} be true in this context even if you can use logical gymnastics to convince yourself that "all" the elements of an empty matrix are nonzero. Octave however duplicates this behavior for {{Codeline|if}} statements containing empty matrices. | because, despite the name, the {{Codeline|all}} is really returning true if none of the elements of the matrix are zero, and since there are no elements, well, none of them are zero. This is an example of [http://en.wikipedia.org/wiki/Vacuous_truth vacuous truth]. But, somewhere along the line, someone decided that {{Codeline|if ([])}} should be false. Mathworks probably thought it just looks wrong to have {{Codeline|[]}} be true in this context even if you can use logical gymnastics to convince yourself that "all" the elements of an empty matrix are nonzero. Octave however duplicates this behavior for {{Codeline|if}} statements containing empty matrices. | ||
== Solvers for singular, under- and over-determined matrices == | |||
Matlab's solvers as used by the operators mldivide (\) and mrdivide (/), use a different approach than Octave's in the case of singular, under-, or over-determined matrices. In the case of a singular matrix, Matlab returns the result given by the LU decomposition, even though the underlying solver has flagged the result as erroneous. Octave has made the choice of falling back to a minimum norm solution of matrices that have been flagged as singular which arguably is a better result for these cases. | Matlab's solvers as used by the operators mldivide (\) and mrdivide (/), use a different approach than Octave's in the case of singular, under-, or over-determined matrices. In the case of a singular matrix, Matlab returns the result given by the LU decomposition, even though the underlying solver has flagged the result as erroneous. Octave has made the choice of falling back to a minimum norm solution of matrices that have been flagged as singular which arguably is a better result for these cases. | ||
Line 816: | Line 913: | ||
Since the mldivide (\) and mrdivide (/) operators are often part of a more complex expression, where there is no room to react to warnings or flags, it should prefer intelligence (robustness) to speed, and so the Octave developers are firmly of the opinion that Octave's approach for singular, under- and over-determined matrices is a better choice than Matlab's. | Since the mldivide (\) and mrdivide (/) operators are often part of a more complex expression, where there is no room to react to warnings or flags, it should prefer intelligence (robustness) to speed, and so the Octave developers are firmly of the opinion that Octave's approach for singular, under- and over-determined matrices is a better choice than Matlab's. | ||
== Octave extensions == | |||
The extensions in Octave over MATLAB syntax are very useful, but might cause issues when sharing with Matlab users. A list of the major extensions that should be avoided to be compatible with Matlab are: | The extensions in Octave over MATLAB syntax are very useful, but might cause issues when sharing with Matlab users. A list of the major extensions that should be avoided to be compatible with Matlab are: | ||
Line 867: | Line 964: | ||
==Does Octave have a GUI?== | ==Does Octave have a GUI?== | ||
Yes! It was officially released with Octave 4.0.0 | Yes! It was officially released with Octave 4.0.0. It was | ||
also available since version 3.8.0 has an experimental feature (use the | also available since version 3.8.0 has an experimental feature (use the | ||
{{Codeline|--force-gui}} option to start Octave). | {{Codeline|--force-gui}} option to start Octave). | ||
Line 890: | Line 987: | ||
made it free software so we could reuse large chunks of it which were | made it free software so we could reuse large chunks of it which were | ||
incorporated in what is now the Octave GUI. | incorporated in what is now the Octave GUI. | ||
=Graphics: backends and toolkits= | |||
==What are the supported graphics backends?== | |||
The current default is OpenGL, through the "qt" graphics toolkit. The "ftlk" toolkit also relies on OpenGL. | |||
Alternatively, Gnuplot can be used as a graphics backend by selecting the "gnuplot" graphics toolkit. | |||
==Why did you replace Gnuplot with an OpenGL backend?== | |||
The development of Octave is committed to being both compatible with Matlab and adding additional features. Toward those ends, the development community has chosen to introduce a native OpenGL backend that supports Matlab handle graphics and its uicontrols. Starting with the 3.8 release, Octave uses OpenGL graphics by default (with FLTK widgets in Octave 3.8 and Qt widgets in Octave 4.0 and later). | |||
==Are there any plans to remove the gnuplot backend?== | |||
There are no plans to remove the gnuplot backend. Even though the default graphics toolkit is now "qt", which uses OpenGL graphics with Qt widgets, the gnuplot backend will still be available as long as our users find it useful. | |||
==How can I implement a new graphics backend/toolkit?== | |||
This is one of those times where the best documentation is to read the existing code. We have three different toolkits in Octave now, so there are some examples to draw from. |