help-octave
[Top][All Lists]
Advanced

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

Re: do_fortran_indexing within functions


From: Quentin Spencer
Subject: Re: do_fortran_indexing within functions
Date: Sun, 06 Jul 2003 23:19:33 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.4) Gecko/20030701

Mike Miller wrote:

In a function defined by an m-file, if I change the value of
do_fortran_indexing, will that make a global change or will it only affect
things within the function?

I would like to write functions that will work both in Octave and in
MATLAB.  Is there an example of a freely-available function that will do
appropriate checks, set the value of do_fortran_indexing only for Octave,
etc.?

Thanks in advance.

Mike
There are probably many ways of doing this. Here's my solution:

function [out]  = octave();
%%% detect Octave vs. MATLAB
tmp     = version;
if(tmp(1)=='2') out     = 1;
else            out     = 0;
end

I put this function in my path so both programs see it, and I use the statement if(octave) in my code to determine which program I'm in when I need it. You'll notice I'm querying the version number. That means this will break in the unlikely scenario that you are using a version 1.x of octave or 2.x of Matlab (both very old versions). That also means you would need to modify this when a 3.x series of octave is released someday.

regards,
Quentin



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