Code covered by the BSD License  

Highlights from
getversion: find MATLAB version number as a double

5.0

5.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 1.83 KB File ID: #17285

getversion: find MATLAB version number as a double

by Tim Davis

 

01 Nov 2007 (Updated 02 Nov 2007)

Portable replacement for verLessThan on old MATLAB releases

| Watch this File

File Information
Description

getversion returns the MATLAB version number as a double, to allow inequality comparisons when checking for ranges of MATLAB versions. The major, sub, and sub-sub version numbers are returned (MATLAB '6.5.2.202935 (R13) Service Pack 2' returns 6.52).

This code is more portable than "ver" (which verLessThan uses) because it does not use structs. It should work on any MATLAB that has the version, sscanf, and length functions.

It has been tested on MATLAB 6.1, 6.5.2., 7.0.1, 7.0.4, 7.1, 7.2, 7.3, 7.4, and 7.5. I no longer have MATLAB 5.x or earlier; please notify me if you test it on those platforms.

See also ver, version, and verLessThan.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
vernum.m

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
10 Jan 2010 Pete

Relatively simple, but hey - I'm lazy. Seems solid. Thanks.

12 Mar 2010 Tim Davis

Comment from the author:

Note that for MATLAB 7.10 (R2010a), this function returns "8". Version 7.10 follows after 7.9, but version 7.10 is not the same as 8.0. When I wrote this code, I assumed that the subversion number (the "y" in "x.y") would always be a single decimal digit.

getversion still returns a value that is monotonically increasing for all MATLAB versions, including 7.10. However, it will fail when MATLAB 8.0 actually comes out.

One fix would be to return a value equal to version+subversion/100, so that "7.1" becomes the number 7.01, "7.10" becomes the number 7.1, and "8.0" would then be 8.0. But this fix would look strange. Printing the version number would lead to confusion.

Maybe I should switch to hexadecimal ...

12 Apr 2010 Jan Simon

I'm using 13.1 (for R13SP1), ..., 2009.1, 2009.2, 2010.1 instead. This is monotonically increasing and will be consistent until TMW delivers a J release... But to be true: This is also just another strange try to live with Matlab's funny numbering methods.

Please login to add a comment or rating.
Updates
02 Nov 2007

minor typo in description (no change to code)

Tag Activity for this File
Tag Applied By Date/Time
version Tim Davis 22 Oct 2008 09:33:26
ver Tim Davis 22 Oct 2008 09:33:26
verlessthan Tim Davis 22 Oct 2008 09:33:26

Contact us at files@mathworks.com