help-octave
[Top][All Lists]
Advanced

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

Re: Detecting Matlab or Octave


From: Peter Brinkmann
Subject: Re: Detecting Matlab or Octave
Date: Thu, 25 Jul 2002 06:43:20 -0500
User-agent: Mutt/1.3.25i

> | 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...

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.
Cheers,
        Peter



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



reply via email to

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