FAQ: Difference between revisions

Jump to navigation Jump to search
3,299 bytes added ,  2 May 2017
→‎Why GNU Octave?: Corrected pronunciation of "GNU"
(→‎Why GNU Octave?: Corrected pronunciation of "GNU")
(31 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://mailman.cae.wisc.edu/listinfo/help-octave help@octave.org mailing list].
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://mailman.cae.wisc.edu/listinfo/help-octave help@octave.org mailing list], you should first check to see if the topic is covered in the manual.
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?==
[http://octave.sourceforge.net/ 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''). [http://octave.sourceforge.net/ 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).
 
[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 36: Line 39:
The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system.
The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system.


GNU is a recursive acronym for “GNU's Not Unix”; it is pronounced guh-noo, approximately like canoe.
GNU is a recursive acronym for “GNU's Not Unix”; it is pronounced g'noo, [https://www.gnu.org/gnu/pronunciation.en.html like “grew” but with the letter “n” instead of “r”].


The Free Software Foundation (FSF) is the principal organizational sponsor of the GNU Project.
The Free Software Foundation (FSF) is the principal organizational sponsor of the GNU Project.
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.
==Why are the developers planning to 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 now uses OpenGL graphics by default with FLTK widgets. A Qt OpenGL toolkit is also [https://github.com/goffioul/QtHandles under development].
There are no plans to remove the gnuplot backend. While a better backend may some day become the new default plotter, the gnuplot backend will still be available as long as our users find it useful.


== 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. One of the best ways for understanding how Octave works is to [[Debugging Octave|run it in a debugger]].
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 easier to patch, so you can discuss improvements to it and submit patches. Or just edit this wiki!
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 184: Line 209:
* First official release of the GUI.
* First official release of the GUI.
* Release of official windows binaries.
* Release of official windows binaries.
* Experimental support for classdef.
* Experimental support for [[classdef]].
* OpenGL graphics with Qt widgets.
* OpenGL graphics with Qt widgets.
* Several functions for reading, writing, and recording of audio.
* Several functions for reading, writing, and recording of audio.
Line 284: Line 309:


* http://www.octave.org/download.html
* http://www.octave.org/download.html
* ftp://ftp.octave.org/pub/octave/
* 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.
Line 298: Line 323:
* 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; Mac OS X; and Windows (versions 98, 2000, XP, Vista, 7 and 8).
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 326: 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 I install ''all'' Octave packages? ==
== How do install or load all Octave packages? ==
Do not do it! Really, there is no reason to do this. Octave Forge has many packages for different needs but it's unlikely that you need all of them. The common misconception is that the more packages one installs, the more complete and powerful its octave installation will be. However, in the same way one would ''never'' install all perl modules, ruby gems or python packages (because it simply makes no sense), one should not install all octave packages. This isn't desirable and it's not even possible.
 
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.


Packages should be installed and loaded selectively. Note that some packages are meant to shadow core functions changing the way Octave works, and different packages can have different implementations of a function with the same name, leading to unpredictable results. Others are just broken or crappy and will break your system. What's worse, some of them packages are even loaded automatically at startup so you may be screwing your octave installation without even realizing it.
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 350: 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 &#61; 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 &#61; 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 428: 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 568: 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, when it works, 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.
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?==


At present, however, the symbolic package is almost useless, since even when you get it to compile and not crash, it cannot handle any array type, which hardly helps for an array-oriented language like Octave. If this limitation is not important to you, attempt to use the symbolic package. If you would like to get this fixed, [http://octave.1599824.n4.nabble.com/Internal-Precision-Symbolic-tp4645257p4645594.html Jordi Gutiérrez Hermoso has volunteered] to fix the package for 5000 USD, which can be obtained from a kickstarter campaign.
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.


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].
There are no plans to support running P-files produced by Matlab in Octave.


=Common problems=
=Common problems=
Line 615: 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 625: 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 635: 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


=Porting programs from Matlab to Octave=
== 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 657: 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.


==How is Octave different from Matlab?==
== Nested Functions ==
 
The major differences between Octave 3.4.N and Matlab R2010b are:
 
===Nested Functions===
Octave has limited support for nested functions. That is
Octave has limited support for nested functions. That is


Line 684: 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===
== 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 694: 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===
== 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===
== 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===
== 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===
== 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 ===
== 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===
== 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===
== 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 ==


Block comments denoted by {{Codeline|#{}} and {{Codeline|#&#125;}}  markers (or {{Codeline|%{}} and {{Codeline|%&#125;}}) 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|#&#125;}}  markers (or {{Codeline|%{}} and {{Codeline|%&#125;}}) are supported by Octave with some limitations. The major limitation is that block comments are not supported within [] or {}.


===Mat-File format===
== 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 734: 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===
== 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===
== 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|&#124;}} operators===
== Short-circuit {{Codeline|&}} and {{Codeline|&#124;}} operators ==


The {{Codeline|&}} and {{Codeline|&#124;}} 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|&#124;&#124;}} short circuit. Note that this means that
The {{Codeline|&}} and {{Codeline|&#124;}} 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|&#124;&#124;}} short circuit. Note that this means that
Line 792: 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===
== 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 831: 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===
== 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 905: 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.
Anonymous user

Navigation menu