Distinguishing Octave from Matlab

John W. Eaton jwe at octave.org
Thu Feb 19 11:36:28 CST 2009


On 19-Feb-2009, José Luis García Pallero wrote:

| Here, you have possible solutions:
| 
| http://www-old.cae.wisc.edu/pipermail/help-octave/2007-April/003809.html
| http://www-old.cae.wisc.edu/pipermail/help-octave/2007-May/003814.html

Probably the best solution is something similar to David's suggestion of:

  function in = inoctave ()
    persistent inout = exist("OCTAVE_VERSION","builtin") != 0;
    in = inout;
  endfunction

but that won't work in Matlab, so you'll need to write it as

  function retval = inoctave ()
    persistent inout;
    if (isempty (inout))
      inout = exist ('OCTAVE_VERSION', 'builtin') ~= 0;
    end
    retval = inout;
  end


If this isn't in the FAQ, it should be.

jwe



More information about the Help-octave mailing list