help-octave
[Top][All Lists]
Advanced

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

Re: Distinguishing Octave from Matlab


From: José Luis García Pallero
Subject: Re: Distinguishing Octave from Matlab
Date: Thu, 19 Feb 2009 18:44:55 +0100

I usually use a function like this:

function [inOctave] = in_octave()
try
OCTAVE_VERSION;
inOctave = 1;
catch
inOctave = 0;
end

What is the difference with the persistent inout = exist("OCTAVE_VERSION","builtin") != 0; version?
Is the evaluation of exist() function faster than OCTAVE_VERSION and try-catch statement?


2009/2/19 John W. Eaton <address@hidden>
On 19-Feb-2009, José Luis García Pallero wrote:

| Here, you have possible solutions:
|
| http://www-old.cae.wisc.edu/pipermail/help-octave/2007-April/003809.html
| http://www-old.cae.wisc.edu/pipermail/help-octave/2007-May/003814.html

Probably the best solution is something similar to David's suggestion of:

 function in = inoctave ()
   persistent inout = exist("OCTAVE_VERSION","builtin") != 0;
   in = inout;
 endfunction

but that won't work in Matlab, so you'll need to write it as

 function retval = inoctave ()
   persistent inout;
   if (isempty (inout))
     inout = exist ('OCTAVE_VERSION', 'builtin') ~= 0;
   end
   retval = inout;
 end


If this isn't in the FAQ, it should be.

jwe



--
*****************************************
José Luis García Pallero
address@hidden
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************

reply via email to

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