Distinguishing Octave from Matlab
José Luis García Pallero
jgpallero at gmail.com
Thu Feb 19 11:05:32 CST 2009
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 <arnoques at gmail.com>
> 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
> Help-octave at octave.org
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
--
*****************************************
José Luis García Pallero
jgpallero at gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090219/119d2e90/attachment.html
More information about the Help-octave
mailing list