help-octave
[Top][All Lists]
Advanced

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

Re: How to determine if you are in octave or matlab


From: David Bateman
Subject: Re: How to determine if you are in octave or matlab
Date: Tue, 01 May 2007 08:09:36 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Tom Holroyd wrote:
> Or more simply:
> 
> function [inOctave] = in_octave()
>       inOctave = exist('OCTAVE_VERSION');
> end
> 

I'd tend to modify that as

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

since OCTAVE_VERSION isn't a file you don't want to search the path
which is expensive, so limit the exist function to just the builtins.
Also once you've calculated the existence once it'll never change and so
the variable can be persistent. Unfortunately output parameters can't be
made persistent and so the "in = inout" is needed...

D.



reply via email to

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