Distinguishing Octave from Matlab

Ben Abbott bpabbott at mac.com
Fri Feb 15 10:43:25 CST 2008


On Feb 15, 2008, at 11:31 AM, David Bateman wrote:

> Ben Abbott wrote:
>>
>> On Feb 15, 2008, at 5:02 AM, David Bateman wrote:
>>
>>> 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
>>
>> Might this be added to the core functions?
>>
>> Ben
>>
> How does that help you if we can't convince mathworks to do the same?
>
> D.

Good point <blushing>

Perhaps an octave version of an existing Matlab function ("ver",  
"version", "verLessThan", ?) could do the job?

 >> help verLessThan
  verLessThan Compare version of toolbox to specified version string.
     verLessThan(TOOLBOX_DIR, VERSION) returns true if the version of
     the toolbox specified by the string TOOLBOX_DIR is older than the
     version specified by the string VERSION, and false otherwise.
     VERSION must be a string in the form 'major[.minor[.revision]]',
     such as '7', '7.1', or '7.0.1'. If TOOLBOX_DIR cannot be found
     on MATLAB's search path, an error is generated.

     Examples:
         if verLessThan('images', '4.1')
             error('Image Processing Toolbox 4.1 or higher is  
required.');
         end

         if verLessThan('matlab', '7.0.1')
             % Put code to run under MATLAB older than MATLAB 7.0.1 here
         else
             % Put code to run under MATLAB 7.0.1 and newer here
         end

     See also matlabpath, ver.

Ben


More information about the Help-octave mailing list