Matlab – How to detect if I’m running MATLAB or Octave

MATLABoctaveportability

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?

Best Answer

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

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