Octave Compatibility FAQ
Octave is mostly compatible with Matlab. Most matlab functions can
be made to run with very little change. With careful coding, you can
get your code to run without change in Matlab and Octave. This document
outlines the things that you need to watch out for.
You may want to start Octave with the option --traditional, which sets
a number flags so that the interpreter handles things in a more
compatible way. See the "porting" section of the octave FAQ:
http://www.octave.org/FAQ.html#SEC24
Be sure you have a recent development version of octave and install
octave-forge.
Resources
- octave-forge
- http://octave.sf.net
- Joao Cardoso's summary of the octave mailing lists
- http://merlin.inescn.pt/~qual/Octave/Octave_links.html
- Octave mailing list archives
- http://www.octave.org/octave-lists/archive/index.html
Language Elements
- Q. Do load and save work for structures?
A. Versions of octave after 2.1.53 support loading and saving of
structures in all of its file formats.
- Q. Does octave support 'end' indexing?
A. Yes, for sufficiently new versions of octave. For older versions,
use length(A) or size(A,1) and size(A,2) as you did before matlab
added the 'end' indexing syntax.
- Q. Why do "grid on" and other commands give me a syntax error?
A. Only Octave built-ins can be ``text functions'' (and only a few
are defined to be). Those which are not built-in, you can mark
as text functions using the following line in your ~/.octaverc:
mark_as_command grid axis
Either that or use the functional form: grid('on')
- Q. Why isn't Octave seeing my .matlabrc file?
A. Because it is not called .octaverc.
- Q. How do I compile my mex functions?
A. See the mex subdirectory of octave-forge/extras.
- Q. debugging?
A. it exists but is not well documented
dbstop if error | -> | debug_on_error = 1
|
dbstop in mfile at lineno | -> | dbstop (func, line)
|
dbclear in mfile at lineno | -> | dbclear (func, line)
|
dbquit | -> | quit
|
dbstack | -> | dbwhere
|
dbcont | -> | dbg_cont
|
dbstep in | -> | dbg_step
|
dbstep | -> | dbg_next
|
dbstatus | -> | dbstatus
|
- Q. assignin
A. Get a recent version of octave.
- Q. [a{:}] = ...
A. Octave can not yet use this construct to define multiple output
arguments. Use "[a{1},a{2}] =" instead. It is expected that this will be
fixed in a future release.
Types
- Q. Does Octave support sparse matrices?
A. Use sparse package in octave-forge.
- Q. Does Octave support nD arrays?
A. Yes, for sufficiently recent versions of octave
- Q. Does octave support cell arrays?
A. Yes, in recent development versions.
- Q. Does octave support different precisions char, short, float, etc?
A. Use 2.1.58 when it is released
- Q. Does octave support symbolic variables?
A. Use symbolic package in octave-forge. There is no support for symbolic
matrices. Symbolic equivalents to builtin functions use uppercase first
letter since Octave can overload built-in functions for user-defined
types (see Sparse answer above for alternative).
- Q. Does octave support arrays of structures?
A. Yes in recent development versions.
Toolboxes
- Q. simulink
A. Doesn't exist. Search for simulink in the
octave archives
for suggested alternatives.
- Q. Is there an optimization tool box?
A. Use octave-forge. This is incomplete. If you need more see
Joao's summary of the octave lists.
- Q. ODE's?
A. Octave has lsode. octave-forge has matlab style ode23, etc.
- Q. Integration?
A. Octave has quad. octave-forge has matlab V5 style quadrature functions.
quadl was recently added to octave-forge.
- Q. Are there matlab style UI functions?
A. No. some work on Tcl/Tk links to Octave, but it is incomplete. There
are two separate branches. See octave archives and octave-forge.
- Q. Signal processing package?
A. octave-forge has many functions. Others are available:
- vco, modulate, demod
- Time Frequency Toolbox
http://www-isis.enst.fr/Applications/tftb/iutsn.univ-nantes.fr/auger/tftb.html
- arcov, armcov, prony, pmusic
- SPC Tools spline directory
ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/tools/spctools/
- Q. Statistics toolbox
A. many of the functions exist but often under different names in base octave
- Q. Control systems toolbox
A. many of the functions exist but often under different names in base octave
Individual functions
- Q. Where do I find the matlab function XXX?
A. Many XXX are in the octave-forge package at http://octave.sf.net. This
is a collection of Octave functions contributed by the user community
but not (yet) included in Octave. If it is not there, then you can
try Joao Cardoso's summary of the octave mailing lists at
http://merlin.inescn.pt/~qual/Octave/Octave_links.html
or search the Octave mailing list archives directly at
http://www.octave.org/octave-lists/archive/index.html
You can also search the matlab contributions site and the wider net for
alternatives to existing matlab functions.
- Q. Why is the title of my graph not showing up on my graph.
A. Octave wants the title before the plot command, matlab
wants it after. Try setting automatic_replot = 1
- Q. logm doesn't work well for ill-conditioned matrices.
A. logm is a stalled work in progress. Ask pkienzle@users.sf.net
to post the work he and Ross Lippert did on this.
- Q. eig(A,B)
A. qz(A,B)
- Q. Can parameters be passed through the call to fsolve() to the
user-supplied function?
A. use FIXES/fsolve.cc on octave-forge.
- Q. inmem
A. who -functions
- Q. computer
A. exists in octave, but probably returns different output
- Q. ! shell command
A. system("shell command")
- Q. gallery, compan, hadamard
A. http://www.ma.man.ac.uk/~higham/testmat.html
- Q. subspace
A. http://www.mathworks.com/support/ftp/linalgv5.shtml
- Q. audio functions
A. octave-forge/main/audio
- Q. datetick
A. gset xdata time; gset timefmt "%d/%m"; gset format x "%b %d"