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 different
There is also a hint in the wiki on the official octave.org website. They propose the following:
Edit: Not all versions of Matlab support '#' for comments so I changed the example to use '%' instead. It works in Matlab R2018 (Linux) and Octave 4.2.2
function foo
%% fancy code that works in both
if (is_octave)
%% use octave super_powers
else
%% do it matlab way
end
%% fancy code that works in both
end
%% subfunction that checks if we are in octave
function r = is_octave ()
persistent x;
if (isempty (x))
x = exist ('OCTAVE_VERSION', 'builtin');
end
r = x;
end