diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index e1e43f4bcf33b17cec7f0f1dc3c3fefca581417c..a063e7493afce5313234a62741b7a3e2f9924472 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -52,7 +52,7 @@ if ~exist('OCTAVE_VERSION')
     addpath([dynareroot '/missing/rows_columns'])
     % Replacement for vec() (inexistent under MATLAB)
     addpath([dynareroot '/missing/vec'])
-    if isempty(ver('stats'))
+    if ~license('test', 'statistics_toolbox')
         % Replacements for functions of the stats toolbox
         addpath([dynareroot '/missing/stats/'])
     end
diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m
index 9ef5f6b6fe94af22e0731b42b3d783cfbcc31eb0..d048a9936ddf8c278a7c4ff08e1c946429e4c921 100644
--- a/matlab/dynare_solve.m
+++ b/matlab/dynare_solve.m
@@ -38,7 +38,7 @@ global options_
 options_ = set_default_option(options_,'solve_algo',2);
 info = 0;
 if options_.solve_algo == 0
-    if ~exist('OCTAVE_VERSION') && isempty(ver('optim'))
+    if ~exist('OCTAVE_VERSION') && ~license('test', 'optimization_toolbox')
         error('You can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox')
     end
     options=optimset('fsolve');
diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m
index 2864fe5f1b7914e5dfdc518e63190cbfb01117cd..70b7045f53d034cb5fff791980140f3186781c2c 100644
--- a/matlab/solve_one_boundary.m
+++ b/matlab/solve_one_boundary.m
@@ -225,7 +225,7 @@ for it_=start:incr:finish
                 if (verbose == 1)
                     disp('steady: fsolve');
                 end
-                if exist('OCTAVE_VERSION') || isempty(ver('optim'))
+                if exist('OCTAVE_VERSION') || ~license('test', 'optimization_toolbox')
                     % Note that fsolve() exists under Octave, but has a different syntax
                     % So we fail for the moment under Octave, until we add the corresponding code
                     error('DYNARE_SOLVE: you can''t use solve_algo=0 since you don''t have Matlab''s Optimization Toolbox')