From 7e72b52677b0fe1b13b7d72c3e17f8d803402d87 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Thu, 20 May 2021 11:23:48 +0200
Subject: [PATCH] model_diagnostics.m: only provide message if imaginary
 component reaches tolerance level

---
 matlab/model_diagnostics.m | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m
index 2bb2b19904..148f219893 100644
--- a/matlab/model_diagnostics.m
+++ b/matlab/model_diagnostics.m
@@ -230,10 +230,12 @@ if ~options.block
         display_problematic_vars_Jacobian(infrow,infcol,M,dr.ys,'dynamic','MODEL_DIAGNOSTICS: ')
     end
     if any(any(~isreal(jacobia_)))
-        problem_dummy=1;
         [imagrow,imagcol]=find(abs(imag(jacobia_))>1e-15);
-        fprintf('\nMODEL_DIAGNOSTICS: The Jacobian of the dynamic model contains imaginary parts. The problem arises from: \n\n')
-        display_problematic_vars_Jacobian(imagrow,imagcol,M,dr.ys,'dynamic','MODEL_DIAGNOSTICS: ')
+        if ~isempty(imagrow)
+            problem_dummy=1;
+            fprintf('\nMODEL_DIAGNOSTICS: The Jacobian of the dynamic model contains imaginary parts. The problem arises from: \n\n')
+            display_problematic_vars_Jacobian(imagrow,imagcol,M,dr.ys,'dynamic','MODEL_DIAGNOSTICS: ')
+        end
     end
     if exist('hessian1','var')
         if any(any(isinf(hessian1) | isnan(hessian1)))
-- 
GitLab