[Top][All Lists]

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

Re: Detecting Matlab or Octave

From: John W. Eaton
Subject: Re: Detecting Matlab or Octave
Date: Thu, 25 Jul 2002 12:14:40 -0500

On 25-Jul-2002, Peter Brinkmann <address@hidden> wrote:

| I've observed some subtle differences between Matlab and Octave that
| need to be dealt with, even if Matlab and Octave have the same feature.
| The 'axis' command comes to mind.


| Doesn't this fail if someone defines 'OCTAVE_VERSION' as a variable
| under Matlab? I don't think this is likely to happen, but still...

Sure, it will fail if someone does that, but is there a way to define
a variable in Matlab that behaves in the same way as one of Octave's
built-in variables?  Normal variables that are defined in Matlab or
Octave have limited scope, or they must be declared global in each
function where they are used.  If you don't think OCTAVE_VERSION is
obscure enough, you could try something like __OCTAVE_VERSION__,
which, unlike OCTAVE_VERSION, is supposed to be a constant that can't
be modified (seems to be broken in 2.1.x, but that should be fixed
shortly).  Or you could even look to see whether that is defined along
with other built-in constants like __OCTAVE_HOME__, __e__, __inf__,
__nan__, etc.

| I suggest using init files for detecting Octave or Matlab. Octave looks
| at .octaverc, and Matlab looks at startup.m. My .octaverc contains the
| lines
|       global isOctave;
|       isOctave=1;
| and my startup.m contains
|       global isOctave;
|       isOctave=0;
| This works rather nicely.

Until someone starts Octave with -f (--norc).  And of course if you
want to pass your code around to others, they have to add this to
their startup files too.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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