[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Distinguishing Octave from Matlab
From: |
David Bateman |
Subject: |
Re: Distinguishing Octave from Matlab |
Date: |
Fri, 15 Feb 2008 11:02:09 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20070914) |
Primoz PETERLIN wrote:
> Hello everyone,
>
> I am sure this question has sprung up before, yet I am unable to find
> it in the archives. I am collaborating on a project with people using
> Matlab. The code is mostly portable, but there are a few quirks on one
> side or the other. The clumsy way which we are using now involves
> commenting out the Matlab code and uncommenting the Octave code on my
> side, while the guy on the other end performs the reverse process.
> What I would want to have is some way with which the script could
> automatically determine whether it is running in Octave or in Matlab,
> i.e., something like
>
> if (octave)
> % some octave code here
> else
> % equivalent matlab code here
> end
>
> Needless to say, it has to work on both ends. My closest match would
> be to use version() and some manually built-in knowledge (i.e., if the
> first character returned by version() is '2' or '3', we are likely to
> be running Octave, and if it is '7', we are likely to be running
> Matlab). Is there a more elegant way to do it?
>
> TIA, Primoz
Use Octave 3.0.0 and use the matlab syntax everywhere, in most cases it
should then just work.. If there are any other differences that prevent
it working then they should be reported as bugs. A function that does
what you want is
function ret = isoctave ()
persistent isoct
if (isempty (isoct))
isoct = exist('OCTAVE_VERSION') ~= 0;
end
ret = isoct;
end
Regards
David
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
- Distinguishing Octave from Matlab, Primoz PETERLIN, 2008/02/15
- Re: Distinguishing Octave from Matlab, Ben Abbott, 2008/02/15
- Re: Distinguishing Octave from Matlab, David Bateman, 2008/02/15
- Re: Distinguishing Octave from Matlab, Ben Abbott, 2008/02/15
- Re: Distinguishing Octave from Matlab, David Bateman, 2008/02/15
- Re: Distinguishing Octave from Matlab, Ben Abbott, 2008/02/15
- Re: Distinguishing Octave from Matlab, Ben Abbott, 2008/02/15