help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check if the environment is Octave or Matlab


From: PhilipNienhuis
Subject: Re: Check if the environment is Octave or Matlab
Date: Fri, 10 Apr 2020 09:17:56 -0500 (CDT)

José Luis García Pallero wrote
> Hello,
> 
> Sometimes I need to check if a function or script is running in Octave
> or Matlab. Usually I make the check as
> 
> if exist('OCTAVE_VERSION')
>     octave = 1;
> else
>     octave = 0;
> end
> 
> Is this the FASTEST way to check the environment or is there any other
> method more suitable?

We have more or less the same in a function "ïsOctave.m" (maybe even with a
persistent variable inside). That function lives in our script library (a
collection of dedicated m-file subdirs) that is in a path set up in a
startup script called by both Matlab and Octave.
No idea if it's faster (I do suspect some function calling overhead) but as
a function it's easy to put in an if clause:
if (isOctave)
  ...
else
  ...
end %if

Philip




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]