time | calls | line |
---|
| | 1 | function result = verLessThan(toolboxstr, verstr)
|
| | 2 | %verLessThan Compare version of toolbox to specified version string.
|
| | 3 | % verLessThan(TOOLBOX_DIR, VERSION) returns true if the version of
|
| | 4 | % the toolbox specified by the string TOOLBOX_DIR is older than the
|
| | 5 | % version specified by the string VERSION, and false otherwise.
|
| | 6 | % VERSION must be a string in the form 'major[.minor[.revision]]',
|
| | 7 | % such as '7', '7.1', or '7.0.1'. If TOOLBOX_DIR cannot be found
|
| | 8 | % on MATLAB's search path, an error is generated.
|
| | 9 | %
|
| | 10 | % Examples:
|
| | 11 | % if verLessThan('images', '4.1')
|
| | 12 | % error('Image Processing Toolbox 4.1 or higher is required.');
|
| | 13 | % end
|
| | 14 | %
|
| | 15 | % if verLessThan('matlab', '7.0.1')
|
| | 16 | % % Put code to run under MATLAB older than MATLAB 7.0.1 here
|
| | 17 | % else
|
| | 18 | % % Put code to run under MATLAB 7.0.1 and newer here
|
| | 19 | % end
|
| | 20 | %
|
| | 21 | % See also MATLABPATH, VER.
|
| | 22 |
|
| | 23 | % Copyright 2006-2014 The MathWorks, Inc.
|
| | 24 |
|
| 4 | 25 | if ~ischar(verstr) || ~ischar(toolboxstr)
|
| | 26 | error(message('MATLAB:verLessThan:invalidInput'))
|
| | 27 | end
|
| | 28 |
|
| | 29 | % We cache the MATLAB version number for better performance.
|
| 4 | 30 | persistent cachedMatlabVer;
|
| | 31 |
|
| 4 | 32 | toolboxIsMatlab = strcmpi(toolboxstr,'matlab');
|
| | 33 |
|
| 4 | 34 | if toolboxIsMatlab && ~isempty(cachedMatlabVer)
|
| 4 | 35 | toolboxParts = cachedMatlabVer;
|
| | 36 | else
|
| | 37 | % The requested product is not MATLAB, or the cached value is empty.
|
| | 38 | toolboxver = ver(toolboxstr);
|
| | 39 | if isempty(toolboxver)
|
| | 40 | error(message('MATLAB:verLessThan:missingToolbox', toolboxstr))
|
| | 41 | end
|
| | 42 |
|
| | 43 | toolboxParts = getParts(toolboxver(1).Version);
|
| | 44 |
|
| | 45 | % If the requested product is MATLAB, cache the version value.
|
| | 46 | if toolboxIsMatlab
|
| | 47 | cachedMatlabVer = toolboxParts;
|
| | 48 | end
|
| | 49 | end
|
| | 50 |
|
| 4 | 51 | verParts = getParts(verstr);
|
| 4 | 52 | if toolboxParts(1) ~= verParts(1) % major version
|
| 2 | 53 | result = toolboxParts(1) < verParts(1);
|
| 2 | 54 | elseif toolboxParts(2) ~= verParts(2) % minor version
|
| 2 | 55 | result = toolboxParts(2) < verParts(2);
|
| | 56 | else % revision version
|
| | 57 | result = toolboxParts(3) < verParts(3);
|
| | 58 | end
|
Other subfunctions in this file are not included in this listing.