(octave.info)How to Distinguish Between Octave and Matlab


Prev: How To Get Help with Octave Up: Trouble
Enter node , (file) or (file)node

D.4 How to Distinguish Between Octave and Matlab
================================================

Octave and MATLAB are very similar, but handle Java slightly different.
Therefore it may be necessary to detect the environment and use the
appropriate functions.  The following function can be used to detect the
environment.  Due to the persistent variable it can be called repeatedly
without a heavy performance hit.

   Example:

     %%
     %% Return: true if the environment is Octave.
     %%
     function retval = isOctave
       persistent cacheval;  % speeds up repeated calls

       if isempty (cacheval)
         cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0);
       end

       retval = cacheval;
     end


automatically generated by info2www version 1.2.2.9