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:05:32 +0100

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

2009/2/19 Pablo <address@hidden>
Sorry to bump in, but I was looking for a way to distinguish octave
from matlab, and I found this thread, with the solution provided by
Ben Abbott:

> Distinguishing between Matlab and Octave may be done as,
>
>       v = ver;
>       if (strcmpi(v(1).Name,'matlab')
>         % Matlab code here
>       elseif (strcmpi(v(1).Name,'octave')
>         % Octave code here
>       end
>
> Ben

 However, when I tried it in matlab, I got unexpected results:

>> v=ver;
>> v(1).Name
ans = Aerospace Blockset
>> help ver
 VER MATLAB, Simulink and toolbox version information.
   VER displays the current MATLAB, Simulink and toolbox version information.
   VER(TOOLBOX_DIR) displays the current version information for the
   toolbox specified by the string TOOLBOX_DIR.


As stated in the help, the command ver gives a long list of version
numbers (one for each toolbox), so it takes a lot of time, several
seconds on my PC. Moreover, the 'matlab' toolbox is not first in that
list. David Bateman suggested the following:

>> v=ver('matlab')
v =
      Name: 'MATLAB'
   Version: '7.0.4'
   Release: '(R14SP2)'
      Date: '21-Jan-2005'

>> v=ver('octave')
v =
0x0 struct array with fields:
   Name
   Version
   Release
   Date

That's way faster, and worked fine. I just suscribed to the list to
second his suggestion, in case it wasn't clear that it works better.
So the code should be something like (I haven't tested it in octave)

v1 = ver('matlab');
v2 = ver('octave');
if (strcmpi(v1.Name,'matlab'))
       % Matlab code here
elseif (strcmpi(v2.Name,'octave'))
       % Octave code here
end


Arnoques
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave



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