https://wiki.octave.org/wiki/api.php?action=feedcontributions&user=69.163.169.146&feedformat=atomOctave - User contributions [en]2021-04-10T22:04:57ZUser contributionsMediaWiki 1.35.1https://wiki.octave.org/wiki/index.php?title=Summer_of_Code_-_Getting_Started&diff=1517Summer of Code - Getting Started2012-07-18T14:11:55Z<p>69.163.169.146: Mention SOCIS</p>
<hr />
<div>The following is distilled from the [[Projects]] page for the benefit of potential [http://code.google.com/soc/Google Summer] [http://sophia.estec.esa.int/socis2012/?q=node/13 of Code] students. Although students are welcome to attempt any of the projects in that page or any of their own choosing, here we offer some suggestions on what good student projects might be.<br />
<br />
= General Guidelines =<br />
<br />
Octave is mostly written in (sadly, mostly undocumented) C++ and its own scripting language (m-scripts), which includes (or should include) most of the Matlab language as a subset. We generally prefer a different Octave house style to the usual Matlab style for m-scripts, but it's primarily a superficial stylistic difference. Additionally, there are bits and pieces of Fortran, Perl, C, awk, and Unix shell scripts here and there. In addition to being familiar with C++ and/or Octave or Matlab's scripting languages, you should probably be familiar or learn about Octave's infrastructure:<br />
<br />
* [http://en.wikipedia.org/wiki/GNU_build_system The GNU build system] is used to build Octave. While you generally don't need to understand too much unless you actually want to change how Octave is built, you should be able to understand enough to get a general idea of how to build Octave. If you've ever done a <tt>configure && make && make install</tt> series of commands, you have already used the GNU build system.<br />
* [http://mercurial.selenic.com/ Mercurial] (abbreviated hg) is the [http://en.wikipedia.org/wiki/Distributed_Version_Control_System distributed version control system] (DVCS) we use for managing our source code. You should have some basic understanding of how a DVCS works, but hg is pretty easy to pick up, especially if you already know a VCS like git or svn.<br />
* You should also read the same [http://www.gnu.org/software/octave/doc/interpreter/Contributing-Guidelines.html#Contributing-Guidelines contributing] [http://hg.savannah.gnu.org/hgweb/octave/file/tip/etc/HACKING guidelines] we have for everyone.<br />
* We primarily use [https://mailman.cae.wisc.edu/listinfo/octave-maintainers mailing lists] for communication. You should follow basic mailing list etiquette. For us, this mostly means "do not [http://en.wikipedia.org/wiki/Top_posting#Top-posting top post]".<br />
* We also have [http://www.gnu.org/software/octave/chat.html an IRC channel]. The atmosphere is more relaxed, and we may talk about things that are not at all related to Octave.<br />
* [http://octave.sf.net Octave-Forge] is a project closely related to Octave where packages reside. They are somewhat analogous to Matlab's toolboxes.<br />
* In addition, you probably should know '''some''' mathematics, engineering, or experimental science or something of the sort. If you've used Matlab before, you probably have already been exposed to the kinds of problems that Octave is used for.<br />
<br />
= Suggested projects =<br />
<br />
The following projects are broadly grouped by category and probable skills required to tackle each. Remember to check [[Projects]] for more ideas if none of these suit you, and your own ideas are always welcome.<br />
<br />
== Numerical ==<br />
<br />
These projects involve implementing certain mathematical functions in Octave.<br />
<br />
'''Required skills''': You should understand quite a bit of mathematics. Words like "eigenvalue", "analytic", and "Taylor series" shouldn't scare you at all. There is probably little C++ experience required, and probably many of these problems can be solved with m-scripts.<br />
<br />
'''Difficulty''': Mid-to-hard depending how much mathematics you know and how well you can read numerical analysis journal articles.<br />
<br />
'''Potential mentor''': Carlo de Falco, Nir Krakauer, Fotios Kasolis, Luis Gustavo Lira<br />
<br />
=== Improve logm, sqrtm, funm ===<br />
<br />
The goal here is to implement some missing Matlab functions related to matrix functions like the [http://en.wikipedia.org/wiki/Matrix_exponential matrix exponential]. There is [http://octave.1599824.n4.nabble.com/matrix-functions-td3137935.html a general discussion] of the problem.<br />
<br />
=== Generalised eigenvalue problem ===<br />
<br />
[http://www.mathworks.com/help/techdoc/ref/eig.html Certain calling forms] of the <tt>eig</tt> function are missing. The problem is to understand what those missing forms are and implement them.<br />
<br />
=== Various sparse matrix improvements ===<br />
<br />
The implementation of sparse matrices in Octave needs several improvements. Any of [[Projects#Sparse Matrices|these]] would be good. The paper by [http://arxiv.org/abs/cs.MS/0604006 Bateman & Adler] is good reading for understanding the sparse matrix implementation.<br />
<br />
=== [http://en.wikipedia.org/wiki/Least-squares_spectral_analysis Least-squares spectral analysis] ===<br />
<br />
Develop and test as an [http://octave.sourceforge.net/ Octave-Forge] package functionality for fast evaluation of harmonics and cross-correlations of unevenly sampled and nonstationary time series, possibly building on [http://www.jstatsoft.org/v11/i02 this paper] (which has C code with interface to R).<br />
<br />
=== Implement solver for initial-boundary value problems for parabolic-elliptic PDEs in 1D ===<br />
<br />
The project will deliver a solver for initial-boundary value problems for parabolic-elliptic PDEs in 1D similar to Matlab's function <tt>pdepe</tt>. A good starting point is the [http://en.wikipedia.org/wiki/Method_of_lines method of lines] for which you can find more details [http://en.wikibooks.org/wiki/Partial_Differential_Equations/Method_of_Lines here] and [http://www.scholarpedia.org/article/Method_of_lines here], whereas an example implementation can be found [http://www.scholarpedia.org/article/Method_of_Lines/Example_Implementation here]. In addition, [http://www.pdecomp.net/ this page] provides some useful material.<br />
<br />
== GUI ==<br />
<br />
Octave is currently working on a new native GUI. It is written in Qt, but it is still not ready for production. There are various ways in which it could be improved.<br />
<br />
'''Required skills''': C++ and Qt. Whatever tools you want to use to write Qt code are fine, but Qt Creator is a popular choice nowadays.<br />
<br />
'''Difficulty''': Mostly medium, depending if you've had Qt or GUI development experience before.<br />
<br />
'''Potential mentor''': Jordi Gutiérrez Hermoso, Michael Goffioul<br />
<br />
=== Finish the Octave GUI ===<br />
<br />
The GUI is currently on its own branch in hg. It is not stable enough and its design is still in flux. It is in a very alpha stage and needs to be turned into a real usable product. At the moment, it consists of the basic building blocks (terminal window, editor, variable browser, history, file browser) that are put together into a main interface. The GUI uses the Qt library. Among the things to improve are:<br />
* define and implement a flexible docking system allowing to place any subwindow at any location<br />
* improve integration with octave: variable browser/editor, debugger, profiler...<br />
* define and implement an option/preferences dialog<br />
* improve additional components like the embedded [http://code.google.com/p/qirc/ IRC client] or the documentation browser<br />
<br />
=== Integrate the GUI with the Octave build system ===<br />
<br />
The current GUI build system is independent of Octave. First one builds and installs Octave, and then the GUI. The goal of this project is to integrate the GUI and make it all build together. Good understanding of both the GNU build system and Qt's ([http://en.wikipedia.org/wiki/Qmake qmake] and the [http://en.wikipedia.org/wiki/Meta-object_System meta-object compiler]) will be necessary here.<br />
<br />
=== Implement a Qt widget for manipulating plots ===<br />
<br />
Octave has had for some time a native OpenGL plotter. The plotter requires some user interaction for manipulating the plots, and it's been using fltk for quite some time. We want to replace this with Qt, so it fits better with the overall GUI look-and-feel and is easier to extend in the future.<br />
<br />
[https://github.com/goffioul/QtHandles QtHandles] is a current work in progress integrating the octave OpenGL renderer plus good support for GUI elements (uicontrol, uimenu, uitoolbar...). This project may initially consists of integrating the existing QtHandles code base into Octave. Then if time permits, further improvements can be made to QtHandles.<br />
<br />
=== Create a better (G)UI for the profiler ===<br />
<br />
During GSoC 2011, Daniel Kraft successfully implemented a profiler for Octave. It needs a better interface and a way to generate reports. This may be done with Qt, but not necessarily, and HTML reports might also be good.<br />
<br />
=== Create a graphical design tool for tuning closed loop control system (control pkg) ===<br />
<br />
When tuning a SISO feedback system it is very helpful to be able to grab a pole or a zero and move them by dragging them with the mouse. As they are moving the software must update all the plotted lines. There should be the ability to display various graphs rlocuse, bode, step, impulse etc. and have them all change dynamically as the mouse is moving. The parameters of the compensator must be displayed and updated.<br />
Potential mentor: Doug Stewart<br />
<br />
== Graphics ==<br />
<br />
Octave has a new native OpenGL plotter (currently via [http://en.wikipedia.org/wiki/Fltk fltk], but we want to move away from that). There are several possible projects involved with it. Michael Goffioul has expressed interest in mentoring these projects.<br />
<br />
'''Required skills''': C++ and OpenGL. General understanding of computer graphics.<br />
<br />
'''Difficulty''': Medium, depending on your previous understanding of the topic.<br />
<br />
'''Potential mentor''': Michael Goffioul<br />
<br />
=== Lighting ===<br />
<br />
Implement transparency and lighting in OpenGL backend(s). A basic implementation was available in [http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/extra/jhandles/ JHandles]. This needs to be ported/re-implement/re-engineered/optimized in the C++ OpenGL renderer of Octave.<br />
<br />
=== Object selection in OpenGL renderer ===<br />
<br />
This project is about the implementation of a selection method of graphics elements within the OpenGL renderer [http://glprogramming.com/red/chapter13.html]<br />
<br />
=== Non-OpenGL renderer ===<br />
<br />
Besides the original gnuplot backend, Octave also contains an OpenGL-based renderer for advanced and more powerful 3D plots. However, OpenGL is not perfectly suited for 2D-only plots where other methods could result in better graphics. The purpose of this project is to implement an alternate graphics renderer for 2D only plots (although 3D is definitely not the focus, extending the new graphics renderer to support basic 3D features should also be taken into account). There is not fix constaints on the toolkit/library to use, but natural candidates are:<br />
* [http://qt.nokia.com Qt]: the GUI is currently written in Qt and work is also in progress to provide a Qt/OpenGL based backend [https://github.com/goffioul/QtHandles]<br />
* [http://en.wikipedia.org/wiki/Cairo_%28software%29 Cairo]: this library is widely used and known to provides high-quality graphics with support for PS/PDF/SVG output.<br />
<br />
=== TeX/LaTeX markup ===<br />
<br />
Text objects in plots (like titles, labels, texts...) in the OpenGL renderer only support plain text mode without any formatting possibility. Support for TeX and/or LaTeX formatting needs to be added.<br />
<br />
The TeX formatting support actually only consists of a very limited subset of the TeX language. This can be implemented directly in C++ into Octave by extending the existing text engine, avoiding to add a dependency on a full TeX system.<br />
<br />
On the other hand, the LaTeX formatting support is expected to provide full LaTeX capabilities. This will require to use an external LaTeX system to produce text graphics in some format (to be specified) that is then integrated into Octave plots.<br />
<br />
The matplotlib project [http://matplotlib.sourceforge.net/users/usetex.html has already done this in Python] and might be used as an example of how to do this in Octave.<br />
<br />
== Interpreter ==<br />
<br />
The interpreter is written in C++, undocumented. There are many possible projects associated with it.<br />
<br />
'''Required skills''': ''Very good'' C and C++ knowledge, possibly also understanding of [http://en.wikipedia.org/wiki/Gnu_bison GNU bison] and [http://en.wikipedia.org/wiki/Flex_lexical_analyser flex]. Understanding how compilers and interpreters are made plus being able to understand how to use a profiler and a debugger will probably be essential skills.<br />
<br />
'''Difficulty''': Mid hard to very hard. Some of the biggest problems will probably be the interpreter.<br />
<br />
'''Potential mentors''': John W. Eaton, Jordi Gutiérrez Hermoso<br />
<br />
=== Implement (or improve?) JIT compiling ===<br />
<br />
Octave's interpreter is ''very'' slow on loops. Implementing JIT compiling would dramatically speed up execution of these loops. This is a very big project, but a dedicated student might make a good attempt of doing this over a summer. There may be some work already in place by the time the summer comes along. The idea is to probably use [http://en.wikipedia.org/wiki/Llvm LLVM] to aid with the JIT compilation.<br />
<br />
=== Improve memory management ===<br />
<br />
From profiling the interpreter, it appears that a lot of time is spending allocating and deallocating memory. A better memory management algorithm might provide some improvement.<br />
<br />
=== Implement classdef classes ===<br />
<br />
Matlab has two kinds of classes: old style @classes and new style classdef. Octave has only implemented the old style. Although the lexer and parser have been updated to recognise the syntax for the new style classdef declarations, they currently do nothing with it. A successful project would design and implement the necessary functionality for these classes. This project is somewhat simpler than others in the interpreter group.<br />
<br />
== Infrastructure ==<br />
<br />
There are several projects closely related to Octave but not exactly core Octave that could be worked on. They are mostly infrastructure around Octave, stuff that would help a lot.<br />
<br />
'''Required skills''': Various. See below.<br />
<br />
'''Difficulty''': Various. See below.<br />
<br />
'''Potential mentor''': Jordi Gutiérrez Hermoso, Carlo de Falco<br />
<br />
=== Finish the Agora website ===<br />
<br />
In 2009, the Mathworks decided to restrict the terms of use Matlab Central, a place dedicated to Matlab collaboration. The Mathworks forbade copyleft licenses and using the "free" code found in Matlab central on anything other than Mathworks products (e.g. forbidding from using it on Octave, even if the authors of the code wanted to allow this). Thus Octave users have no place to centrally, quickly, and conveniently share Octave code. '''''Note''': is this still true?'' There seems to be plenty of, say, BSD-licensed code on Matlab Central. Mathworks can't really override such licenses. So what's the problem? <br />
<br />
In response to this, a website started to form, [http://agora.panocha.org.mx/ Agora Octave].<br />
<br />
This should be relatively easy webdev in Python using [http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django].<br />
<br />
=== Give maintenance to the Emacs octave mode ===<br />
<br />
[http://en.wikipedia.org/wiki/Emacs Emacs] has an octave-mode that requires a lot of maintenance. This should also be an easy project if you already use Emacs and [http://en.wikipedia.org/wiki/Elisp elisp].<br />
<br />
=== Improve binary packaging ===<br />
<br />
We would like to be able to easily generate binary packages for Windows and Mac OS X. Right now, it's difficult and tedious to do so. Any way to help us do this in a faster way would be appreciated. Required knowledge is understanding how building binaries in Windows and Mac OS X works. Medium difficulty.<br />
<br />
=== Installation of packages ===<br />
We would like to enhance the management of Octave-forge packages from within Octave environment. Currently there is a working (but rather monolithic) function that is used to do the job. The work would be to improve the way Octave interacts with the package server. Since the functionality is already sketched by the current function, the most important skill is software design.<br />
<br />
'''Minimum requirements''': Ability to read and write Octave code. Minimal FTP/HTTP knowledge.<br />
<br />
'''Difficulty''': Easy<br />
<br />
== Octave-Forge packages ==<br />
<br />
=== Rewrite symbolic package ===<br />
Octave's current [http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/symbolic/ symbolic] package for symbolic computation is outdated, fragile and limited in its capabilities. The new symbolic package should offer better Matlab compatibility, for example handling of symbolic matrices. Like the current symbolic package, the new package could use the proven [http://www.ginac.de/ GiNaC] library for symbolic computations.<br />
<br />
The work would be to integrate GiNaC by using Octave's objects and classes. This can be done in C++ in a way similar to Michele Martone's new [http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/sparsersb/ sparsersb] package.<br />
<br />
'''Required skills''': C++. Ability to understand Octave and GiNaC API documentation.<br />
<br />
'''Difficulty''': medium.<br />
<br />
'''Potential mentor''': Lukas Reichlin<br />
<br />
=== RSB Octave interface ===<br />
The Robotics Service Bus ([https://code.cor-lab.de/projects/rsb RSB]) is a message-oriented, event-driven middleware aiming at scalable integration of robotics and software systems in diverse environments.<br />
It provides Octave a flexible and standardized way to communicate with other programs like Sage (or any Python application), Maxima (or any Lisp application). At the same time it gives a general solution to communicate with hardware platforms.<br />
<br />
The work would consist on writing a small extendable package that provides minimal communication functionality. The package should follow the RSB standard such that its integrating it with existing robotic hardware and the successful [http://www.ros.org/wiki/ ROS].<br />
<br />
'''Required skills''': C++. Understadning of [https://code.cor-lab.de/projects/rsb/wiki RSB basics].<br />
<br />
'''Difficulty''': medium.<br />
<br />
'''Potential mentor''': Arne Nordmann, Juan Pablo Carbajal<br />
<br />
<br />
=== Low-Level I/O ===<br />
<br />
Octave currently provides file I/O and sockets for communicating with the outside world. Octave is currently not capable of communicating over serial interfaces (RS232) or, for example, I2C and CAN (although an workaround for serial I/O exists, however the author could never get it to work in an acceptable way). The project would provide communication interfaces in octave, allowing octave to directly communicate with measurement systems, data acquisition systems, sensors, robotic systems and the like. <br />
<br />
RS232 interfaces are often deemed "legacy", however there is not only an enormous amount of expensive, existing instrumentation equipment out there, still using RS232, but due to the simplicity it is still common in new embedded systems, often bridged via USB providing a virtual com port.<br />
<br />
Potential interfaces to support could, for example, be RS232, I2C, CAN, LIN, SPI, parallel port, GPIB, USB HID, USBTMC. One initial task of the student would be to select a subset of these standards to support, taking, for example, existing drivers into account.<br />
<br />
'''Required skills''': C++, system programming knowledge, knowledge of Octave's current handling of file descriptors.<br />
<br />
'''Difficulty''': Mostly medium, depending depending on existing driver support and experience with the protocols<br />
<br />
'''Potential mentor''': Michael Godfrey (?)</div>69.163.169.146https://wiki.octave.org/wiki/index.php?title=FAQ&diff=874FAQ2012-03-11T21:07:45Z<p>69.163.169.146: /* Profiler */</p>
<hr />
<div>This is a list of frequently asked questions (FAQ) for Octave users.<br />
<br />
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 Octave, or need help for something that is not covered by the Octave manual or the FAQ, please use the help@octave.org mailing list.<br />
<br />
This FAQ is intended to supplement, not replace, the Octave manual. Before posting a question to the help@octave.org mailing list, you should first check to see if the topic is covered in the manual.<br />
<br />
=General=<br />
<br />
==What is Octave?==<br />
<br />
Octave is a high-level interactive language, primarily intended for numerical computations that is mostly compatible with Matlab.1<br />
<br />
Octave can do arithmetic for real, complex or integer-valued scalars and matrices, solve sets of nonlinear algebraic equations, integrate functions over finite and infinite intervals, and integrate systems of ordinary differential and differential-algebraic equations.<br />
<br />
Octave uses the GNU readline library to handle reading and editing input. By default, the line editing commands are similar to the cursor movement commands used by GNU Emacs, and a vi-style line editing interface is also available. At the end of each session, the command history is saved, so that commands entered during previous sessions are not lost.<br />
<br />
The Octave distribution includes a 650+ page Texinfo manual. Access to the complete text of the manual is available via the doc command at the Octave prompt.<br />
<br />
==Who uses Octave?==<br />
<br />
Lots of people. It seems that universities use it for research and teaching, companies of all sizes, for development, individuals. This question comes often on Octave mailing lists, see [[Who Uses Octave?]] for a few answers<br />
<br />
==Who develops Octave?==<br />
<br />
Discussions about writing the software that would eventually become Octave started in about 1988 with James B. Rawlings and John W. Eaton at the University of Texas. John W. Eaton was the original author of Octave, starting full-time development in February 1992. He is still the primary maintainer. The community of users/developers has in addition contributed some code and fuels the discussion on the mailing lists help@octave.org (user forum), maintainers@octave.org (development issues), and octave-dev@lists.sourceforge.net (all things related to the Octave Forge repository of user-contributed functions).<br />
<br />
==Why '''GNU''' Octave?==<br />
<br />
The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system.<br />
<br />
GNU is a recursive acronym for “GNU's Not Unix”; it is pronounced guh-noo, approximately like canoe.<br />
<br />
The Free Software Foundation (FSF) is the principal organizational sponsor of the GNU Project.<br />
<br />
Octave became GNU Octave in 1997 (beginning with version 2.0.6). This meant agreeing to consider Octave a part of the GNU Project and support the efforts of the FSF. A big part of this effort is to adhere to the [http://www.gnu.org/prep/standards/standards.html GNU coding standards] and to benefit from GNU's infrastructure (e.g. [http://hg.savannah.gnu.org/hgweb/octave/ code hosting] and [http://bugs.octave.org bug tracking]). Additionally, Octave receives [https://my.fsf.org/donate/working-together/octave sponsorship] from the FSF's Working Together fund. However, Octave is not and has never been developed by the FSF.<br />
<br />
For more information about the GNU project, see http://www.gnu.org.<br />
<br />
==What version should I use?==<br />
<br />
In general, you will find the latest version on http://www.octave.org/download.html. It is recommended to use the stable version of octave for general use, and the development version if you want the latest features and are willing to tolerate instability.<br />
<br />
A list of user-visible changes since the last release is available in the file NEWS. The file ChangeLog in the source distribution contains a more detailed record of changes made since the last release.<br />
<br />
==On what platforms does Octave run?==<br />
<br />
Octave runs on various Unices—at least Linux and Solaris, Mac OS X, Windows and anything you can compile it on. Binary distributions exist at least for Debian, SUSE, Fedora and RedHat Linuxes (Intel and AMD CPUs, at least), for Mac OS X and Windows' 98, 2000, XP, Vista, and 7.<br />
<br />
Two and three dimensional plotting is fully supported using gnuplot and an experimental OpenGL backend.<br />
<br />
The underlying numerical solvers are currently standard Fortran ones like LAPACK, LINPACK, ODEPACK, the BLAS, etc., packaged in a library of C++ classes. If possible, the Fortran subroutines are compiled with the system's Fortran compiler, and called directly from the C++ functions. If that's not possible, you can still compile Octave if you have the free Fortran to C translator f2c.<br />
<br />
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.<br />
<br />
==Why are the developers planning to replace Gnuplot with an OpenGL backend?==<br />
<br />
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. The introduction of the experimental fltk graphics toolkit is the first product of this effort. As of the 3.6.N series, the fltk toolkit is approximately as advanced as is the Gnuplot toolkit. It is not yet decided if the fltk toolkit is to become the default backend, or if another OpenGL implementation will replace Gnuplot as the default backend (An QtOpenGL toolkit is also under development).<br />
<br />
==How can I cite Octave?==<br />
<br />
Pointing to http://www.octave.org is good, because that gives people a direct way to find out more. If citation of a URL is not allowed by a publisher, or if you also want to point to a traditional reference, then you can cite the Octave manual:<br />
<br />
@BOOK{eaton:2008,<br />
author = "John W. Eaton, David Bateman, and Søren Hauberg",<br />
title = "GNU Octave Manual Version 3",<br />
publisher = "Network Theory Limited",<br />
year = "2008",<br />
isbn = "0-9546120-6-X"<br />
}<br />
<br />
=Licensing issues=<br />
<br />
==If I write code using Octave do I have to release it under the GPL?==<br />
<br />
The answer depends on precisely how the code is written and how it works.<br />
<br />
Code written entirely in the scripting language of Octave (interpreted code in .m files) may be released under the terms of whatever license you choose.<br />
<br />
Code written using Octave's native plug-in interface (also known as a .oct file) necessarily links with Octave internals and is considered a derivative work of Octave and therefore must be released under terms that are compatible with the GPL.<br />
<br />
Code written using Octave's implementation of the Matlab MEX interface may be released under the terms of whatever license you choose, provided that the following conditions are met:<br />
<br />
# The plugin should not use any bindings that are specific to Octave. In other words, the MEX file must use the MEX interface only, and not also call on other Octave internals. It should be possible in principle to use the MEX file with other programs that implement the MEX interface (e.g., Matlab).<br />
# The MEX file should not be distributed together with Octave in such a way that they effectively create a single work. For example, you should not distribute the MEX file and Octave together in a single package such that Octave automatically loads and runs the MEX file when it starts up. There are other possible ways that you might effectively create a single work; this is just one example.<br />
<br />
A program that embeds the Octave interpreter (e.g., by calling the "octave_main" function), or that calls functions from Octave's libraries (e.g., liboctinterp, liboctave, or libcruft) is considered a derivative work of Octave and therefore must be released under terms that are compatible with the GPL.<br />
<br />
==Since the MEX interface allows plugins to be distributed under terms that are incompatible with the GPL, does this mean that you are encouraging people to to write non-free software for Octave?==<br />
<br />
No. The original reason for implementing the MEX interface for Octave was to allow Octave to run free software that uses MEX files (the particular goal was to run SundialsTB in Octave). The intent was to liberate that software from Matlab and increase the amount of free software available to Octave users, not to enable people to write proprietary code for Octave. For the good of the community, we strongly encourage users of Octave to release the code they write for Octave under terms that are compatible with the GPL.<br />
<br />
==I wrote a program that links with Octave libraries and I don't want to release it under the terms of the GPL. Will you change the license of the Octave libraries for me?==<br />
<br />
No. Instead of asking us to change the licensing terms for Octave, we recommend that you release your program under terms that are compatible with the GPL so that the free software community can benefit from your work the same as you have benefited from the work of all the people who have contributed to Octave.<br />
<br />
=What's new in Octave=<br />
==What's new in version series 3.6.N and 3.7.N of Octave==<br />
<br />
Several new features have been added to the 3.6.N series. The full details are in the NEWS file, but in brief 3.6.N series brings:<br />
<br />
* Perl compatible regular expressions<br />
* A profiler has been added.<br />
* Broadcasting enabled for all built-in binary element-wise operators.<br />
* The statistical distribution functions have been overhauled.<br />
* The functions strread(), textscan(), and textread() have been rewritten.<br />
* Performance of all m-file string functions has been improved.<br />
* The qhull geometry functions have been revamped.<br />
* Date/time functions have been updated.<br />
* Matlab compatible preference functions have been added.<br />
* Various handle graphics functions have be introduced.<br />
* The parfor keyword is now recognized.<br />
<br />
==Features added in version series 3.4.N and 3.5.N of Octave==<br />
Here are some features that have been around since 3.4.N<br />
<br />
* Many improvements to native OpenGL plotting<br />
* ARPACK now distributed with Octave<br />
* Indexing optimisations<br />
* FTP object using libcurl<br />
* Better consistency with ismatrix, issquare, and issymetric<br />
* Function handles aware of overloaded functions<br />
* More efficient matrix division by making a single LAPACK call<br />
* Other optimisations in matrix operations<br />
* bsxfun optimised for basic arithmetic functions<br />
* Matlab-style ignoring of output arguments using <tt>~</tt><br />
* Many optimisations of the accumarray function<br />
* Sparse matrix indexing has been rewritten for speed<br />
* Configuration pseudo-variables like page_screen_output accept a "local" option argument to limit their scope to function scope<br />
* The pkg command now accepts a -forge option to pull packages directly from Octave-forge<br />
* Several dlmread improvements<br />
* Octave now uses gnulib for better cross-platform compatibility<br />
<br />
==Features added in version series 3.2.N and 3.3.N of Octave==<br />
Here are some features that have been around since 3.2.N<br />
<br />
* integer types<br />
* fixed point arithmetic<br />
* sparse matrices<br />
* linear programming code based on GLPK<br />
* 64-bit compilation support<br />
* gzipped files and stream and consequently support of Matlab v7 files<br />
* better support for both msvc and mingw<br />
* a fully compatible MEX interface<br />
* many many other minor features and compatibility changes<br />
* an experimental OpenGL graphics toolkit to replace gnuplot<br />
* object orient programming<br />
* block comments<br />
* imwrite and imread (based on the GraphicsMagick library)<br />
* 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.<br />
* Single precision type<br />
* Improved array indexing <br/> The underlying code used for indexing of arrays has been completely rewritten and so the indexing of arrays is now significantly faster.<br />
<br />
==Features available since 2.1.N==<br />
Here are some older features that have been around since 2.1.N:<br />
<br />
* NDArrays<br />
* cells<br />
<br />
==Coming in a future release==<br />
The 3.7.N series is the current development release and will become a 3.8.N release in the future. This series brings the following new features:<br />
<br />
* A GUI for Octave (based on Qt4)<br />
* The default graphics toolkit it planned to be changed from Gnuplot to an OpenGL fltk toolkit.<br />
<br />
=What documentation exists for Octave?=<br />
<br />
Besides the current wiki, there are other important sources of documentation and help for Octave.<br />
<br />
==What documentation exists for Octave?==<br />
<br />
The Octave distribution includes a 650+ page manual that is also distributed under the terms of the GNU GPL. It is available on the web at http://www.octave.org/docs.html and you will also find there instructions on how to order a paper version.<br />
<br />
The complete text of the Octave manual is also available using the GNU Info system via the GNU Emacs, info, or xinfo programs, or by using the <tt>doc</tt> command to start the GNU info browser directly from the Octave prompt.<br />
<br />
If you have problems using this documentation, or find that some topic is not adequately explained, indexed, or cross-referenced, please report it on http://bugs.octave.org.<br />
<br />
==Getting additional help==<br />
<br />
If you can't find an answer to your question, the help@octave.org mailing list is available for questions related to using, installing, and porting Octave that are not adequately answered by the Octave manual or by this document.<br />
<br />
==User community==<br />
<br />
To subscribe to the list, go to http://www.octave.org/archive.html and follow the link to the subscription page for the list.<br />
<br />
Please do not send requests to be added or removed from the mailing list, or other administrative trivia to the list itself.<br />
<br />
An archive of old postings to the help-octave mailing list is maintained on http://www.octave.org/archive.html.<br />
<br />
You will also find some user advice and code spread over the web. Good starting points are the Octave Wiki http://wiki.octave.org and Octave-Forge http://octave.sourceforge.net<br />
<br />
We also have [http://www.octave.org/chat.html an IRC chat room].<br />
<br />
==I think I have found a bug in Octave.==<br />
<br />
“I think I have found a bug in Octave, but I'm not sure. How do I know, and who should I tell?”<br />
<br />
First, see the section [http://www.octave.org/bugs.html on bugs and bug reports in the Octave manual]. When you report a bug, make sure to describe the type of computer you are using, the version of the operating system it is running, and the version of Octave that you are using. Also provide enough code and configuration details of your operating system so that the Octave maintainers can duplicate your bug.<br />
<br />
=How can I obtain Octave?=<br />
<br />
==Source code==<br />
<br />
Source code is available on the Octave development site, where you are sure to get the latest version.<br />
<br />
* http://www.octave.org/download.html<br />
* ftp://ftp.octave.org/pub/octave/<br />
<br />
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.<br />
<br />
==Pre-compiled binary packages==<br />
<br />
The Octave project does not distribute binary packages, but other projects do. For an up-to-date listing of packagers, see:<br />
<br />
* http://www.octave.org/download.html<br />
* [[Build From Source]]<br />
<br />
As of today, Octave binaries are available at least on Debian, Ubuntu, RedHat, Suse and Fedora GNU/Linuxen, Mac OS X, Windows' 98, 2000 and XP, Vista, and 7.<br />
<br />
==How do I get a copy of Octave for (some other platform)?==<br />
<br />
Octave currently runs on Unix-like systems, Mac OS X, and Windows. It should be possible to make Octave work on other systems as well. If you are interested in porting Octave to other systems, please contact [mailto:maintainers@octave.org the maintainers' mailing list].<br />
<br />
=Installation issues and problems= <br />
<br />
Octave 3.4 requires approximately 1.3 GB of disk storage to unpack and compile from source (considerably less if you don't compile with debugging symbols). Once installed, Octave requires approximately 355 MB of disk space (again, considerably less if you don't compile with debugging symbols, approximately 50 MB).<br />
<br />
==What else do I need?==<br />
<br />
To compile Octave, you will need a recent version of GNU Make. You will also need GCC 4.3 or later, although GCC 4.4 or later is recommended.<br />
<br />
'''You must have GNU Make to compile octave'''. Octave's Makefiles use features of GNU Make that are not present in other versions of make. GNU Make is very portable and easy to install.<br />
<br />
==Can I compile Octave with another C++ compiler?==<br />
<br />
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].<br />
<br />
== Further links ==<br />
* Check the page [[Installation]] for more detailed information about installing Octave.<br />
<br />
=Coding=<br />
<br />
==What features are unique to Octave?==<br />
<br />
Although most of the Octave language will be familiar to Matlab users, it has some unique features of its own.<br />
<br />
=== Functions defined on the command-line===<br />
Functions can be defined by entering code on the command line, a feature not supported by Matlab. For example, you may type:<br />
<br />
octave:1> function s = hello_string (to_who)<br />
> ## Say hello<br />
> if nargin<1, to_who = "World"; end<br />
> s = ["Hello ",\<br />
> to_who];<br />
> endfunction<br />
octave:2> hello_string ("Moon")<br />
ans = Hello Moon<br />
<br />
As a natural extension of this, functions can also be defined in script files (m-files whose first non-comment line isn't <tt>function out = foo (...)</tt>)<br />
<br />
===Comments with #===<br />
<br />
The pound character, <tt>#</tt>, may be used to start comments, in addition to <tt>%</tt>. See the previous example. The major advantage of this is that as <tt>#</tt> is also a comment character for unix script files, any file that starts with a string like <tt>#! /usr/bin/octave -q</tt> will be treated as an octave script and be executed by octave.<br />
<br />
===Strings delimited by double quotes "===<br />
<br />
The double quote, <tt>"</tt>, may be used to delimit strings, in addition to the single quote <tt>'</tt>. See the previous example. Also, double-quoted strings include backslash interpretation (like C++, C, and Perl) while single quoted are uninterpreted (like Matlab and Perl).<br />
<br />
===Line continuation by backslash===<br />
<br />
Lines can be continued with a backslash, <tt>\</tt>, in addition to three points <tt>...</tt>. See the previous example.<br />
<br />
===Informative block closing===<br />
<br />
You may close function, for, while, if, ... blocks with endfunction, endfor, endwhile, ... keywords in addition to using end. As with Matlab, the end (or endfunction) keyword that marks the end of a function defined in a .m file is optional.<br />
<br />
===Coherent syntax===<br />
<br />
Indexing other things than variables is possible, as in:<br />
<br />
octave:1> [3 1 4 1 5 9](3)<br />
ans = 4<br />
octave:2> cos([0 pi pi/4 7])(3)<br />
ans = 0.70711<br />
<br />
In Matlab, it is for example necessary to assign the intermediate result <tt>cos([0 pi pi/4 7])</tt> to a variable before it can be indexed again.<br />
<br />
===Exclamation mark as not operator===<br />
<br />
The exclamation mark <tt>!</tt> (aka “Bang!”) is a negation operator, just like the tilde <tt>~</tt>:<br />
<br />
octave:1> if ! strcmp (program_name, "octave"),<br />
> "It's an error"<br />
> else<br />
> "It works!"<br />
> end<br />
ans = It works!<br />
Note however that Matlab uses the <tt>!</tt> operator for shell escapes, for which Octave requires using the system command.<br />
<br />
===Increment and decrement operators===<br />
<br />
If you like the <tt>++</tt>, <tt>+=</tt> etc operators, rejoice! Octave includes the C-like increment and decrement operators <tt>++</tt> and <tt>--</tt> in both their prefix and postfix forms, in addition to <tt>+=</tt>, <tt>-=</tt>, <tt>*=</tt>, <tt>/=</tt>, <tt>^=</tt>, <tt>.*=</tt>, <tt>./=</tt>, and <tt>.^=</tt>.<br />
<br />
For example, to pre-increment the variable x, you would write ++x. This would add one to x and then return the new value of x as the result of the expression. It is exactly the same as the expression x = x + 1.<br />
<br />
To post-increment a variable x, you would write x++. This adds one to the variable x, but returns the value that x had prior to incrementing it. For example, if x is equal to 2, the result of the expression x++ is 2, and the new value of x is 3.<br />
<br />
For matrix and vector arguments, the increment and decrement operators work on each element of the operand.<br />
<br />
===Unwind-protect===<br />
<br />
In addition to try-catch blocks, Octave supports an alternative form of exception handling modeled after the unwind-protect form of Lisp. The general form of an unwind_protect block looks like this:<br />
<br />
unwind_protect<br />
body<br />
unwind_protect_cleanup<br />
cleanup<br />
end_unwind_protect<br />
<br />
Where body and cleanup are both optional and may contain any Octave expressions or commands. The statements in cleanup are guaranteed to be executed regardless of how control exits body.<br />
<br />
The unwind_protect statement is often used to reliably restore the values of global variables that need to be temporarily changed.<br />
<br />
Matlab can be made to do something similar with their <tt>OnCleanUp</tt> function that was introduced in 2008a. Octave also has <tt>onCleanup</tt> since version 3.4.0.<br />
<br />
===Built-in ODE and DAE solvers===<br />
<br />
Octave includes LSODE and DASSL for solving systems of stiff ordinary differential and differential-algebraic equations. These functions are built in to the interpreter.<br />
<br />
==How does Octave solve linear systems?==<br />
<br />
In addition to consulting Octave's source for the precise details, you can read the Octave manual for a complete high-level description of the algorithm that Octave uses to decide how to solve a particular linear system, e.g. how the backslash operator <tt>A\x</tt> will be interpreted. Sections [http://www.gnu.org/software/octave/doc/interpreter/Techniques-Used-for-Linear-Algebra.html#Techniques-Used-for-Linear-Algebra Techniques Used for Linear Algebra] and [http://www.gnu.org/software/octave/doc/interpreter/Sparse-Linear-Algebra.html Linear Algebra on Sparse Matrices] from the manual describe this procedure.<br />
<br />
=How do I...?=<br />
<br />
==do xxxx?==<br />
<br />
You are probably looking for the function ''lookfor''. This function searches the help text of all functions for a specific string and returns a list of functions. Note that by default it will only search the first line of the help text (check ''help lookfor'' at the octave prompt for more). The following example helps to find the function to calculate correlation coefficient in a matrix:<br />
<br />
octave:1> lookfor ("correlation")<br />
corr2 Returns the correlation coefficient between I and J.<br />
cor Compute correlation.<br />
corrcoef Compute correlation.<br />
spearman Compute Spearman's rank correlation coefficient RHO for each of the variables sp<br />
autocor Return the autocorrelations from lag 0 to H of vector X.<br />
<br />
Also, there's a high chance that the function name has a suggestive name, and so you can try auto-completion to get some hints. For the previous example, typing ''corr'' at the octave promp followed by pressing [Tab] twice would suggest the following:<br />
<br />
octave:2> corr<br />
corr2 corrcoef<br />
<br />
==How do I erase a figure?== <br />
<br />
closeplot(); <br />
closefig(number)<br />
<br />
==How do I set the number of displayed decimals?==<br />
<br />
octave:1> format long<br />
octave:2> pi<br />
pi = 3.14159265358979<br />
octave:3> format short<br />
octave:4> pi<br />
pi = 3.1416<br />
<br />
==How do I vary the line thickness?==<br />
<br />
* There's plpot_octave, but the one in debian doesn't work for me.<br />
* Here's my octave hack for it--- http://gnufans.net/~deego/pub/octave/plot_width.m This one simply draws the line multiple times.<br />
* You can edit the .eps file manually or using sed and awk.<br />
* Export the graph as fig file (gset term fig thickness 2). This also allows for easy postediting with xfig and export to formats not supported by gnuplot.<br />
* The gplot command of octave does not support gnuplot's linewidth parameter Thus you must use the graw() function for sending this option directly to gnuplot, eg. <br />
graw('replot "" notitle with lines lw 4\n');<br />
*Search the [http://octave.1599824.n4.nabble.com/ octave archives] for more.<br />
<br />
==How do I call an octave function from C++?==<br />
<br />
*Here is an untested code snippet for calling rand([9000,1]), modified from a post by HerberFarnsworth? to help-octave on 2003-05-01:<br />
<br />
#include <octave/oct.h><br />
...<br />
ColumnVector NumRands(2);<br />
NumRands(0) = 9000;<br />
NumRands(1) = 1;<br />
octave_value_list f_arg, f_ret;<br />
f_arg(0) = octave_value(NumRands);<br />
f_ret = feval("rand",f_arg,1);<br />
Matrix unis(f_ret(0).matrix_value());<br />
<br />
==How do I create a full semilog/log grid==<br />
<br />
gset grid mxtics mytics<br />
gset grid lw 2, lw 0.1<br />
grid("on");<br />
<br />
One can use postscript enhancement for proper axis<br />
gset format x "10^{%%L}"<br />
or<br />
gset format y "10^{%%L}" <br />
<br />
==How do I change colour/line definition in gnuplot postscript?==<br />
Here is a awk script to get a rainbow colour map<br />
<br />
#!/bin/awk -f<br />
<br />
BEGIN {<br />
split("0 4 6 7 5 3 1 2 8", rainbow, " ");<br />
split("7 3 1 0 2 4 6 5 8", invraim, " ");<br />
}<br />
<br />
$1 ~ /\/LT[0-8]/ {<br />
n = substr($1, 4, 1);<br />
if (n == 0)<br />
lt = "{ PL [] 0.9 0.1 0.1 DL } def";<br />
else if (n == 1)<br />
lt = "{ PL [4 dl 2 dl] 0.1 .75 0.1 DL } def";<br />
else if (n == 2)<br />
lt = "{ PL [2 dl 3 dl] 0.1 0.1 0.9 DL } def";<br />
else if (n == 3)<br />
lt = "{ PL [1 dl 1.5 dl] 0.9 0 0.8 DL } def";<br />
else if (n == 4)<br />
lt = "{ PL [5 dl 2 dl 1 dl 2 dl] 0.1 0.8 0.8 DL } def";<br />
else if (n == 5)<br />
lt = "{ PL [4 dl 3 dl 1 dl 3 dl] 0.9 0.8 0.2 DL } def";<br />
else if (n == 6)<br />
lt = "{ PL [2 dl 2 dl 2 dl 4 dl] 0.5 0.3 0.1 DL } def";<br />
else if (n == 7)<br />
lt = "{ PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.4 0 DL } def";<br />
else if (n == 8)<br />
lt = "{ PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def";<br />
$0 = sprintf("/LT%d %s", rainbow[n+1], lt);<br />
##$0 = sprintf("/LT%x %s", invraim[n+1], lt);<br />
##$0 = sprintf("/LT%x %s", n, lt);<br />
}<br />
<br />
{ print; }<br />
<br />
==How do I tell if a file exists?==<br />
<br />
Look at functions like exist, file_in_path.. and the other functions that their descriptions point to.<br />
<br />
<br />
==How do I create a plot without a window popping up (ie, a plot to a file)?==<br />
<br />
figure(1, "visible", "off");<br />
plot(sin(1:100));<br />
print -deps "/tmp/sin.eps"<br />
<br />
One can set that behaviour as default:<br />
<br />
set(0, 'defaultfigurevisible', 'off');<br />
<br />
=Common problems=<br />
<br />
==When I try plotting from a script, why am I not seeing anything?==<br />
<br />
If you are running an Octave script that includes a plotting command, the script and Octave may terminate immediately. So the plot window does show up, but immediately closes when Octave finishes execution.<br />
<br />
A common solution is to put a <tt>pause</tt> command at the end of your script.<br />
<br />
==How do I get sound output in Windows?== <br />
See http://www.octave.org/octave-lists/archive/help-octave.2003/msg01567.html for a start.<br />
<br />
==Why does Octave segfault when using "clear all;"?==<br />
<br />
This is a known problem if you have one of the following packages loaded:<br />
<br />
* ann<br />
* database<br />
* ftp <br />
<br />
See http://www.nabble.com/Segmentation-Fault---Clear-all-td21998563.html for a discussion<br />
<br />
==Octave takes a long time to find symbols.==<br />
<br />
Octave uses the genpath function to recursively add directories to the list of directories searched for function files. Check the list of directories with the path command. If the path list is very long check your use of the genpath function.<br />
<br />
==When plotting Octave occasionally gives me errors like <tt>gnuplot> 9 0.735604 line 26317: invalid command</tt>.==<br />
There is a known bug in gnuplot 4.2 that can cause an off by one error while piping data to gnuplot. It has been fixed in gnuplot 4.4.<br />
<br />
If you have obtained your copy of Octave from a distribution please file a bug report requesting that the fix reported in the above bug report be included.<br />
<br />
==I cannot install a package. Octave complains about a missing mkoctfile.==<br />
<br />
Most distributions split Octave into several packages. The script mkoctfile is then part of a separate package:<br />
<br />
* Debian/Ubuntu<br/><br />
<tt>aptitude install octave-headers</tt><br />
<br />
* Fedora<br/><br />
<tt>yum install octave-devel</tt><br />
<br />
=Porting programs from Matlab to Octave=<br />
<br />
People often ask<br />
<br />
<blockquote><br />
I wrote some code for Matlab, and I want to get it running under Octave. Is there anything I should watch out for?<br />
</blockquote><br />
<br />
or alternatively<br />
<br />
<blockquote><br />
I wrote some code in Octave, and want to share it with Matlab users. Is there anything I should watch out for?<br />
</blockquote><br />
<br />
which is not quite the same thing. There are still a number of differences between Octave and Matlab, however in general differences between the two are considered as bugs. Octave might consider that the bug is in Matlab and do nothing about it, but generally functionality is almost identical. If you find a difference between Octave behavior and Matlab, then you should send a description of this difference (with code illustrating the difference, if possible) to http://bugs.octave.org.<br />
<br />
Furthermore, Octave adds a few syntactical extensions to Matlab that might cause some issues when exchanging files between Matlab and Octave users. As both Octave and Matlab are under constant development the information in this section is subject to change at anytime.<br />
<br />
You should also look at the page http://octave.sourceforge.net/packages.html and http://octave.sourceforge.net/doc/ that has a function reference that is up to date. You can use this function reference to see the number of octave function that are available and their Matlab compatibility.<br />
<br />
==How is Octave different from Matlab?==<br />
<br />
The major differences between Octave 3.4.N and Matlab R2010b are:<br />
<br />
===Nested Functions===<br />
Octave has limited support for nested functions. That is<br />
<br />
function y = foo (x)<br />
y = bar(x)<br />
function y = bar (x)<br />
y = ...;<br />
end<br />
end<br />
<br />
is equivalent to<br />
<br />
function y = foo (x)<br />
y = bar(x)<br />
end<br />
function y = bar (x)<br />
y = ...;<br />
end<br />
<br />
The main difference with Matlab is a matter of scope. While nested functions have access to the parent function's scope in Matlab, no such thing is available in Octave, due to how Octave essentially “un-nests” nested functions.<br />
<br />
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.<br />
<br />
===Differences in core syntax===<br />
<br />
There a few core Matlab syntaxes that are not accepted by Octave, these being<br />
<br />
* Some limitations on the use of function handles. The major difference is related to nested function scoping rules (as above) and their use with function handles.<br />
<br />
* Some limitations of variable argument lists on the LHS of an expression, though the most common types are accepted.<br />
<br />
* Matlab classdef object oriented programming is not yet supported, though work is underway and when development moves on to Octave 3.5 this will be included in the development tree.<br />
<br />
===Differences in core functions===<br />
<br />
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.<br />
<br />
===Just-In-Time compiler===<br />
<br />
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.<br />
<br />
===Compiler===<br />
<br />
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.<br />
<br />
===Graphic handles===<br />
<br />
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.<br />
<br />
===GUI functions ===<br />
<br />
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 Tcl/Tk, VTK and Zenity included in the Octave Forge project (http://octave.sourceforge.net) 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.<br />
<br />
===Simulink===<br />
<br />
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.<br />
<br />
===MEX-Files===<br />
<br />
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).<br />
<br />
===Block comments===<br />
<br />
Block comments denoted by <tt>#{</tt> and <tt>#}</tt> markers (or <tt>%{</tt> and <tt>%}</tt>) are supported by Octave with some limitations. The major limitation is that block comments are not supported within [] or {}.<br />
<br />
===Mat-File format===<br />
<br />
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.<br />
<br />
Although Octave can load inline function handles saved by Matlab, it can not yet save them.<br />
<br />
Finally, Some multi-byte Unicode characters aren't yet treated in mat-files.<br />
<br />
===Profiler===<br />
<br />
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.<br />
<br />
===Toolboxes===<br />
<br />
Octave is a community project and so the toolboxes that exist are donated by those interested in them through the Octave Forge website (http://octave.sourceforge.net). These might be lacking in certain functionality relative to the Matlab toolboxes, and might not exactly duplicate the Matlab functionality or interface.<br />
<br />
===Short-circuit <tt>&</tt> and <tt>|</tt> operators===<br />
<br />
The <tt>&</tt> and <tt>|</tt> operators in Matlab short-circuit when included in a condition (e.g. an <tt>if</tt> or <tt>while</tt> statement) and not otherwise. In Octave only the <tt>&&</tt> and <tt>||</tt> short circuit. Note that this means that<br />
<br />
if (a | b)<br />
...<br />
end<br />
<br />
and<br />
<br />
t = a | b;<br />
if t<br />
...<br />
end<br />
<br />
have different semantics in Matlab. This is really a Matlab bug, but there is too much code out there that relies on this behaviour to change it. Prefer the <tt>||</tt> and <tt>&&</tt> operators in <tt>if</tt> statements if possible. If you need to use code written for Matlab that depends on this buggy behaviour, you can enable it since Octave 3.4.0 with the following command:<br />
<br />
do_braindead_shortcircuit_evaluation(1)<br />
<br />
Note that the difference with Matlab is also significant when either argument is a function with side effects or if the first argument is a scalar and the second argument is an empty matrix. For example, note the difference between<br />
<br />
t = 1 | []; ## results in [], so...<br />
if (t) 1, end ## in if ([]), this is false.<br />
<br />
and<br />
<br />
if (1 | []) 1, end ## short circuits so condition is true.<br />
<br />
Another case that is documented in the Matlab manuals is that<br />
<br />
t = [1, 1] | [1, 2, 3]; ## error<br />
if ([1, 1] | [1, 2, 3]) 1, end ## OK<br />
<br />
Also Matlab requires the operands of <tt>&&</tt> and <tt>||</tt> to be scalar values but Octave does not (it just applies the rule that for an operand to be considered true, every element of the object must be nonzero or logically true).<br />
<br />
Finally, note the inconsistence of thinking of the condition of an <tt>if</tt> statement as being equivalent to <tt>all(X(:))</tt> when <tt>X</tt> is a matrix. This is true for all cases EXCEPT empty matrices:<br />
<br />
if ([0, 1]) == if (all ([0, 1])) ==> i.e., condition is false.<br />
if ([1, 1]) == if (all ([1, 1])) ==> i.e., condition is true.<br />
<br />
However,<br />
<br />
if ([])<br />
<br />
is not the same as<br />
<br />
if (all ([]))<br />
<br />
because, despite the name, the <tt>all</tt> 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 <tt>if ([])</tt> should be false. Mathworks probably thought it just looks wrong to have <tt>[]</tt> 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 <tt>if</tt> statements containing empty matrices.<br />
<br />
===Solvers for singular, under- and over-determined matrices===<br />
<br />
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.<br />
<br />
In the case of under- or over-determined matrices, Octave continues to use a minimum norm solution, whereas Matlab uses an approach that is equivalent to<br />
<br />
function x = mldivide (A, b)<br />
[Q, R, E] = qr(A);<br />
x = [A \ b, E(:, 1:m) * (R(:, 1:m) \ (Q' * b))]<br />
end<br />
<br />
While this approach is certainly faster and uses less memory than Octave's minimum norm approach, this approach seems to be inferior in other ways.<br />
<br />
A numerical question arises: how big can the null space component become, relative to the minimum-norm solution? Can it be nicely bounded, or can it be arbitrarily big? Consider this example:<br />
<br />
m = 10;<br />
n = 10000;<br />
A = ones(m, n) + 1e-6 * randn(m,n);<br />
b = ones(m, 1) + 1e-6 * randn(m,1);<br />
norm(A \ b)<br />
<br />
while Octave's minimum-norm values are around 3e-2, Matlab's results are 50-times larger. For another issue, try this code:<br />
<br />
m = 5;<br />
n = 100;<br />
j = floor(m * rand(1, n)) + 1;<br />
b = ones(m, 1);<br />
A = zeros(m, n);<br />
A(sub2ind(size(A),j,1:n)) = 1;<br />
x = A \ b;<br />
[dummy,p] = sort(rand(1,n));<br />
y = A(:,p)\b;<br />
norm(x(p)-y)<br />
<br />
It shows that unlike in Octave, mldivide in Matlab is not invariant with respect to column permutations. If there are multiple columns of the same norm, permuting columns of the matrix gets you different result than permuting the solution vector. This will surprise many users.<br />
<br />
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.<br />
<br />
===Octave extensions===<br />
<br />
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:<br />
<br />
Comments in octave can be marked with <tt>#</tt>. This allows POSIX systems to have the first line as <tt>#! octave -q</tt> and mark the script itself executable. Matlab doesn't have this feature due to the absence of comments starting with <tt>#</tt>".<br />
<br />
Code blocks like if, for, while, etc can be terminated with block specific terminations like endif. Matlab doesn't have this and all blocks must be terminated with end.<br />
<br />
Octave has a lisp-like <tt>unwind_protect</tt> block that allows blocks of code that terminate in an error to ensure that the variables that are touched are restored. You can do something similar with try/catch combined with <tt>rethrow (lasterror ())</tt> in Matlab, however rethrow and lasterror are only available in Octave 2.9.10 and later. Matlab 2008a also introduced <tt>OnCleanUp</tt> that is similar to <tt>unwind_protect</tt>, except that the object created by this function has to be explicitly cleared in order for the cleanup code to run.<br />
<br />
Note that using try/catch combined with <tt>rethrow (lasterror ())</tt> can not guarantee that global variables will be correctly reset, as it won't catch user interrupts with Ctrl-C. For example<br />
<br />
global a<br />
a = 1;<br />
try<br />
_a = a;<br />
a = 2<br />
while true<br />
end<br />
catch<br />
fprintf ('caught interrupt\n');<br />
a = _a;<br />
rethrow (lasterror());<br />
end<br />
<br />
compared to<br />
<br />
global a<br />
a = 1;<br />
unwind_protect<br />
_a = a;<br />
a = 2<br />
while true<br />
end<br />
unwind_protect_cleanup<br />
fprintf ('caught interrupt\n');<br />
a = _a;<br />
end<br />
<br />
Typing Ctrl-C in the first case returns the user directly to the prompt, and the variable ''a'' is not reset to the saved value. In the second case the variable ''a'' is reset correctly. Therefore Matlab gives no safe way of temporarily changing global variables.<br />
<br />
Indexing can be applied to all objects in Octave and not just variables. Therefore <tt>sin(x)(1:10);</tt> for example is perfectly valid in Octave but not Matlab. To do the same in Matlab you must do <tt>y = sin(x); y = y([1:10]);</tt><br />
<br />
Octave has the operators <tt>++</tt>, <tt>–</tt>, <tt>-=</tt>, <tt>+=</tt>, <tt>*=</tt>, etc. As Matlab doesn't, if you are sharing code these should be avoided.<br />
<br />
Character strings in Octave can be denoted with double or single quotes. There is a subtle difference between the two in that escaped characters like <tt>\n</tt> (newline), <tt>\t</tt> (tab), etc are interpreted in double quoted strings but not single quoted strings. This difference is important on Windows platforms where the <tt>\</tt> character is used in path names, and so single quoted strings should be used in paths. Matlab doesn't have double quoted strings and so they should be avoided if the code will be transferred to a Matlab user.<br />
<br />
==GUI==<br />
This is a small section but it's probably one of the most frequent questions.<br />
<br />
===Is there a GUI for octave?===<br />
No.<br />
<br />
===Is there a GUI planned for octave?===<br />
Yes but it's still in development though. You can try to download the gui branch of octave and compile it yourself. Seems to be stable enough.<br />
<br />
===How come there's still no GUI for octave?===<br />
The octave prompt is really really good. Also, some people are of the opinion that a GUI actually slows down the learning of the language.<br />
<br />
Also, octave is a community project. It has the functionalities that its users are willing to spend time working on. The fact there's no GUI for octave only shows that there's not enough interest on it (despite the amount of times this question shows up).</div>69.163.169.146