[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detecting Matlab or Octave
From: |
Paul Kienzle |
Subject: |
Re: Detecting Matlab or Octave |
Date: |
Thu, 25 Jul 2002 13:01:24 -0400 |
On Thu, Jul 25, 2002 at 06:43:20AM -0500, Peter Brinkmann wrote:
>
> > | Is there some way to detect, inside a function, whether that function is
> > | running under Matlab or Octave?
> > |
> > | A really lame method would be to test for facilities that exist in Matlab
> > | but not Octave using the exist() function, but of course that fails when
> > | the facilities finally appear in Octave.
> >
> > Why does it fail if Octave later provides the feature you are looking
> > for (I'm assuming tests like this would be done for each missing
> > feature that you need to work around)?
>
> 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.
>
> > | Does anyone have a good idea about this, or is there a known good method?
> >
> > What about
> >
> > if (exist ('OCTAVE_VERSION'))
> > % Octave-specific stuff here
> > else
> > % Stuff suitable for the other leading brand goes here
> > end
> >
> > ?
>
> 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...
exist returns a larger number if the variable is a built-in. Check what
exist('OCTAVE_VERSION') returns in octave against what OCTAVE_VERSION=1;
exist('OCTAVE_VERSION') returns in matlab.
- Paul Kienzle
address@hidden
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------