Go to the first, previous, next, last section, table of contents.

Porting programs from MATLAB to Octave

"I wrote some code for MATLAB, and I want to get it running under Octave. Is there anything I should watch out for?"

The differences between Octave and MATLAB typically fall into one of three categories:

  1. Irrelevant.
  2. Known differences, perhaps configurable with a user preference variable.
  3. Unknown differences.

The first category, irrelevant differences, do not affect computations and most likely do not affect the execution of function files. Some examples are:

When typing `help function', Octave displays the first set of comment lines after the function declaration, but MATLAB the first set of comment lines starting from the beginning of the file.

The differences of the second category are usually because the authors of Octave decided on a better (subjective) implementation that the way MATLAB does it, and so introduced "user preference variables" so that you can customize Octave's behavior to be either MATLAB-compatible or to use Octave's new features. To make Octave more MATLAB-compatible, put the following statements in your `~/.octaverc' file. This is a partial list of the user preference variables that should be changed to get MATLAB-compatible behavior. (It is partial because not all the differences are currently known, and when they become known, this document lags behind.)

  do_fortran_indexing = 'true';
  treat_neg_dim_as_zero = 'true';
  empty_list_elements_ok = 'true';
  implicit_str_to_num_ok = 'true';
  whitespace_in_literal_matrix = 'traditional';
  prefer_zero_one_indexing = 'true';

Some other known differences are:

The third category of differences is (hopefully) shrinking. 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 bug-octave@che.utexas.edu.

An archive of old postings to the Octave mailing lists is maintained on ftp.che.utexas.edu in the directory `/pub/octave/MAILING-LISTS'.

Go to the first, previous, next, last section, table of contents.