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:44:18 -0500 (CDT)

PhilipNienhuis wrote
> 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

Now I remember that someone suggested us to declare a global variable
isOctave=0 in Matlab's startup.m file (to be put in <MATLAB>\bin\ next to
matab.exe), and similarly, global isOctave=1 in the site-wide .octaverc file
(in share/octave/<version>/m/startup/
That should have the lowest overhead. 
But in controlled (locked down) environments it may require a bit of effort
to get IT people to do this for you.

P.



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



reply via email to

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