How do I detect if I'm running MATLAB or Octave?

lindelof picture lindelof · Feb 11, 2010 · Viewed 9.6k times · Source

I need to write code that should run equally well in Octave and on MATLAB. Problem is that it needs to do some GUI stuff, which MATLAB and Octave handle completely differently.

Is there a way I can detect if I'm running MATLAB or Octave, in order to call the right function?

Answer

Amro picture Amro · Feb 11, 2010

You could use the following test to differentiate Octave from MATLAB:

isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;