diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m
index 197953fe1eb267876d250397a42796df76dd0e5b..92122514f145d69ce8774803cb1af13c5cdaa40d 100644
--- a/matlab/model_diagnostics.m
+++ b/matlab/model_diagnostics.m
@@ -209,11 +209,12 @@ if any(any(isinf(jacobia_) | isnan(jacobia_)))
     fprintf('\nMODEL_DIAGNOSTICS: The Jacobian of the dynamic model contains Inf or NaN. The problem arises from: \n\n')
     display_problematic_vars_Jacobian(infrow,infcol,M,dr.ys,'dynamic','MODEL_DIAGNOSTICS: ')
 end
-if any(any(isinf(hessian1) | isnan(hessian1)))
-    problem_dummy=1;
-    fprintf('\nMODEL_DIAGNOSTICS: The Hessian of the dynamic model contains Inf or NaN.\n')
+if exist('hessian1','var')
+    if any(any(isinf(hessian1) | isnan(hessian1)))
+        problem_dummy=1;
+        fprintf('\nMODEL_DIAGNOSTICS: The Hessian of the dynamic model contains Inf or NaN.\n')
+    end
 end
-
 if problem_dummy==0
     fprintf('MODEL_DIAGNOSTICS:  No obvious problems with this mod-file were detected.\n')
 end