Skip to content
Ido Rosen edited this page Jan 4, 2014 · 1 revision

Table of Contents

Matlab vs Octave

Octave is a free version of Matlab. However, there are some reasons to prefer Matlab:

  • It has much better graphics
  • It has a much better IDE (integrated development environment), including an excellent editor, debugger, and profiler
  • It is faster than Octave, since it has a just-in-time compiler.
  • It has more functions.
There are two main cases when you may need the free version: when running code on the cloud, and when you want to make your code runnable by general users who may not want to buy matlab. For the former, it is best to use the matlab compiler, which lets you generate stand-alone code. (Note this code is not generally faster than interpreted code; basically the stand-alone code contains a matlab virtual machine inside it.) For the latter, you may want to use octave. Unfortunately, converting code from matlab to octave is not entirely pain-free, for reasons we explain below.

Compatability of Octave and Matlab

  • Octave's legend function has a different interface than Matlab's.
  • Octave sets random seeds differently than Matlab, hence random data is not consistent.
  • Octave does not yet (Fall 2011) support Matlab's Object Oriented System and has only limited support for the old style OO system, (e.g. no operator overloading support).
  • Octave does not support the concatenation of a cell array of strings and a string, you must first wrap the string in a cell.
  • Vertical concatenation of nested cell arrays of strings, e.g. vertcat(s{:}) behaves differently in Matlab and Octave. Matlab returns a cell array of strings, Octave returns a character array.
  • Calling bsxfun(@eq, a(:), sparse(1:n)) fails in Octave, but works if you omit the call to sparse.
  • The octave function behaves slightly differently than Matlab's If you call in Octave while in the same directory as , octave returns , whereas Matlab will return the full absolute filepath. This causes problems when calling .
  • The following command fails, (does nothing) in Octave: . The problem is the option.
  • Here is a list of files in Matlab 2008a, missing in Octave.
  • Octave does not yet support Matlab's new Object Oriented System and has only limited support for the old style OO system, (e.g. no operator overloading support). This should have no impact on PMTK3, which no longer uses objects. However, PMTK1 and PMTK2 will not work in Octave, and nor will graphviz4matlab.
  • The 'rows' function in Minka's lightspeed toolbox masks the built in Octave 'rows' function, which causes subtle bugs in unexpected places.
  • Matlab uses different file extensions for different versions of .mex files, depending on the operating system. Octave does not, so it is difficult to include pre-compiled versions for multiple machines. See this page for more details.

Running Octave from within Matlab

Octave can be launched within the Matlab command window, (useful for development purposes) by using the following code. Add these lines to a Matlab shortcut for single button access.

Type to return to Matlab.

Code in the Matlab editor can be executed in Octave, (while its running) by highlighting it and pressing the key.

Additional links