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: James Sherman Jr.
Subject: Re: Check if the environment is Octave or Matlab
Date: Fri, 10 Apr 2020 14:56:13 -0400


On Fri, Apr 10, 2020 at 2:50 PM Steph Bredenhann <address@hidden> wrote:
On 2020/04/10 16:17, 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




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



I tried isOctave with following results

>> isOctave
error: 'isOctave' undefined near line 1 column 1
>>

Is there a package that I should load? I run Octave 5.2 on Ubuntu 18.04.3

--
Steph

Hi Steph,

I think you misread that response.  I believe what Philip was saying that he put that code (starting with if exist(...)) in a file called isOctave.  I don't believe there is a built in function to do what you're asking.  The caveat was that, if you're looking for the FASTEST way, it would evoke some function call overhead than putting that code directly into your code, so it would be relatively slower than putting it inline.

James Sherman

reply via email to

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