diff --git a/matlab/newrat.m b/matlab/newrat.m
index 0eeb3087e975968c2834acd3d83acb615ef9f45a..af6bf9baca07df3f9606c382bbc520f0c4603fb6 100644
--- a/matlab/newrat.m
+++ b/matlab/newrat.m
@@ -236,7 +236,7 @@ while norm(gg)>gtol && check==0 && jit<nit
                 end
                 H = igg;
             end
-        else
+        elseif analytic_derivation,
             [fvalx,gg,hh]=feval(func0,xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
             hhg=hh;
             H = inv(hh);