Version number 2021a Version='9.10' is confusing. Why not using '10.0'

14 views (last 30 days)
I used ver('MATLAB') in Matlab release 2021a and got
Name: 'MATLAB'
Version: '9.10'
Release: '(R2021a)'
Date: '14-Nov-2020'
The version string/number can be confusing because numerically 9.10 becomes 9.1 and 'feels' lower than the previous Matlab release 2020b (Version '9.9'). Why not using 10.0?
  6 Comments
Rik
Rik on 8 Apr 2021
The mistake is doing str2double(ver('MATLAB').Version). You should not parse the version like that. You should either do something similar to what I showed in my answer, or use verLessThan.
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. Documentation for verLessThan doc verLessThan
Thomas Rutten
Thomas Rutten on 8 Apr 2021
Good to mention verLessThan! I forgot this function. This topic is answered now.

Sign in to comment.

Accepted Answer

Rik
Rik on 8 Apr 2021
Edited: Rik on 9 Apr 2021
Versioning is a complex and hotly debated topic. Generally you want to increment the first number if you have a really big upgrade that introduces and/or breaks many functions.
In the past the first number has been incremented from 6 to 7 with the introduction of anonymous function (and an overhaul of the graphics and the JIT?). Version 8.0 (R2012b) introduced a completely new UI with a toolstrip. Interestingly the introduction of HG2 (a complete overhaul of how graphic objects behave) didn't merit an increment, but simply appeared in 8.4. If I recall correctly I have seen some suggestions that you could enable HG2 prior to that (for beta testing purposes), but I have never experimented with that.
The next increment came with R2016a, which introduced live scripts and the ability to pause an execution. It is not hard to see how those two changes would require many changes, ultimately leading to incrementing the main version number.
There is a big gap between R14 and R2012b. This has led to R2012a being version 7.14, so the issue you are pointing out has been bigger.
The main message is this: don't treat the version number as a decimal number. You need to think of it as major.minor.bugfix.build (I don't know if Mathworks is actually using this system; you could compare the version numbers between the release version and an updated version).
To answer the question in your title: apparently Mathworks didn't think the changes were so large that incrementing the main version number would be appropriate.
If you really want steadily increasing numbers you can either use something like my ifversion function (or verLessThan), or use code like this:
%only works for v7.2 and later
% R2020b is 20201 with this code
%10*str2double(regexprep(version,'.*R(\d\d\d\d)([ab]).*','${[$1 sprintf(''.%d'',double($2)-97)]}'))
[10,1]*(sscanf(regexp(version,'R\d{4}[ab]','match','once'),'R%d%c')-[0;97])
ans = 20210
  2 Comments
Stephen23
Stephen23 on 9 Apr 2021
Edited: Stephen23 on 9 Apr 2021
str = version
str = '9.10.0.1613233 (R2021a)'
str = regexp(str,'R\d{4}[ab]','match','once')
str = 'R2021a'
num = [10,1]*(sscanf(str,'R%d%c')-[0;97])
num = 20210

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!