Home > matlab > matlab_ver_less_than.m

matlab_ver_less_than

PURPOSE ^

function r = matlab_ver_less_than(verstr)

SYNOPSIS ^

function r = matlab_ver_less_than(verstr)

DESCRIPTION ^

 function r = matlab_ver_less_than(verstr)

 Returns 1 if current Matlab version is strictly older than
 the one given in argument.

 It basically does the same job than verLessThan(), which is
 only available since Matlab 7.4.

 Note that this function will fail under Octave.

 INPUTS
    verstr: a string of the format 'x.y' or 'x.y.z'
    
 OUTPUTS
    r: 0 or 1

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function r = matlab_ver_less_than(verstr)
0002 % function r = matlab_ver_less_than(verstr)
0003 %
0004 % Returns 1 if current Matlab version is strictly older than
0005 % the one given in argument.
0006 %
0007 % It basically does the same job than verLessThan(), which is
0008 % only available since Matlab 7.4.
0009 %
0010 % Note that this function will fail under Octave.
0011 %
0012 % INPUTS
0013 %    verstr: a string of the format 'x.y' or 'x.y.z'
0014 %
0015 % OUTPUTS
0016 %    r: 0 or 1
0017 %
0018 % SPECIAL REQUIREMENTS
0019 %    none
0020 
0021 % Copyright (C) 2008-2009 Dynare Team
0022 %
0023 % This file is part of Dynare.
0024 %
0025 % Dynare is free software: you can redistribute it and/or modify
0026 % it under the terms of the GNU General Public License as published by
0027 % the Free Software Foundation, either version 3 of the License, or
0028 % (at your option) any later version.
0029 %
0030 % Dynare is distributed in the hope that it will be useful,
0031 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0032 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0033 % GNU General Public License for more details.
0034 %
0035 % You should have received a copy of the GNU General Public License
0036 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0037 
0038 ver_struct = ver('matlab');
0039 cur_verstr = ver_struct.Version;
0040 
0041 r = get_ver_numeric(cur_verstr) < get_ver_numeric(verstr);
0042 
0043 
0044 function x = get_ver_numeric(verstr)
0045 nums = sscanf(verstr, '%d.%d.%d')';
0046 if length(nums) < 3
0047     nums(3) = 0;
0048 end
0049 x = nums * [1; 0.01; 0.0001 ];

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005