1function [hasLicense] = user_has_matlab_license(toolbox) 2%[hasLicense] = user_has_matlab_license(toolbox) 3% checks for license using the appropriate function call 4% 5% INPUTS 6% toolbox: string for toolbox name 7% 8% OUTPUTS 9% hasLicense: bool indicating whether or not the user has the license 10% 11% SPECIAL REQUIREMENTS 12% none 13 14% Copyright (C) 2012-2017 Dynare Team 15% 16% This file is part of Dynare. 17% 18% Dynare is free software: you can redistribute it and/or modify 19% it under the terms of the GNU General Public License as published by 20% the Free Software Foundation, either version 3 of the License, or 21% (at your option) any later version. 22% 23% Dynare is distributed in the hope that it will be useful, 24% but WITHOUT ANY WARRANTY; without even the implied warranty of 25% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26% GNU General Public License for more details. 27% 28% You should have received a copy of the GNU General Public License 29% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 30 31if matlab_ver_less_than('7.12') 32 hasLicense = license('test', toolbox); 33else 34 [hasLicense, ~] = license('checkout',toolbox); 35end 36if ~hasLicense 37 return 38end 39switch toolbox 40 %use function unique to toolbox 41 case 'statistics_toolbox' 42 n = 'gppdf'; 43 case 'optimization_toolbox' 44 n='fsolve'; 45 case 'GADS_Toolbox' 46 n='simulannealbnd'; 47 case 'control_toolbox' 48 n='dlyap'; 49end 50hasInstallation=check_toolbox_installation(n); 51if ~hasInstallation 52 hasLicense=0; 53 return 54end 55end 56 57function hasInstallation=check_toolbox_installation(n) 58if isempty(n) 59 hasInstallation=0; 60else 61 %follows description in ver-help 62 pat = '(?<=^.+[\\/]toolbox[\\/])[^\\/]+'; 63 ver_string=regexp(which(n), pat, 'match', 'once'); 64 a=ver(ver_string); 65 if isempty(a) 66 hasInstallation=0; 67 else 68 hasInstallation=1; 69 end 70end 71end