


MATLABVERSION Sortable version number for current Matlab.
V = MATLABVERSION returns a sortable version number for the instance
of Matlab invoking MATLABVERSION. The number is derived by calling V
= ver('Matlab'); V = V.Version; and converting the result into a
number by removing all decimal points after the first.
MATLABVERSION caches the version number and repeated calls are thus
significantly faster than similar calls to VER.
(Note that the sortable property will break if TMW ever releases an
update with more than one digit in the update number. E.g.,
MATLABVERSION assumes that versions such as 7.10.1 do not occur, in
keeping with TMW nomenclature to date.)
See also VER, VERSION.

0001 function vout = matlabversion 0002 %MATLABVERSION Sortable version number for current Matlab. 0003 % V = MATLABVERSION returns a sortable version number for the instance 0004 % of Matlab invoking MATLABVERSION. The number is derived by calling V 0005 % = ver('Matlab'); V = V.Version; and converting the result into a 0006 % number by removing all decimal points after the first. 0007 % 0008 % MATLABVERSION caches the version number and repeated calls are thus 0009 % significantly faster than similar calls to VER. 0010 % 0011 % (Note that the sortable property will break if TMW ever releases an 0012 % update with more than one digit in the update number. E.g., 0013 % MATLABVERSION assumes that versions such as 7.10.1 do not occur, in 0014 % keeping with TMW nomenclature to date.) 0015 % 0016 % See also VER, VERSION. 0017 0018 persistent v 0019 0020 if (isempty(v)), % only look this up the first time ... 0021 % Get version string 0022 v = ver('Matlab'); 0023 v = v.Version; 0024 0025 % Replace all decimal points after the first 0026 dots = regexp(v,'\.'); 0027 v(dots(2:end)) = ''; 0028 0029 % Convert to number 0030 v = str2num(v); 0031 end 0032 0033 vout = v;