From a6af79e10d6316fa25b7284f7eab933dc04b473c Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Fri, 10 Dec 2021 09:05:55 +0100
Subject: [PATCH] evaluate_steady_state.m: correctly condition debugging info
 on existence of objects from steady state file

(cherry picked from commit 741772d51447c163606bc9aea92b6e95bd660f1e)
---
 matlab/evaluate_steady_state.m | 47 ++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m
index f800d836a1..00eac444c6 100644
--- a/matlab/evaluate_steady_state.m
+++ b/matlab/evaluate_steady_state.m
@@ -141,28 +141,31 @@ if options.ramsey_policy
                 fprintf('%s\n',M.endo_names{nanrow(iter)});
             end
         end
-        nan_indices_mult=find(isnan(resids(1:n_multipliers)));
-        if any(nan_indices_mult)
-            fprintf('evaluate_steady_state: The steady state results NaN for auxiliary equation %u.\n',nan_indices_mult);            
-            fprintf('evaluate_steady_state: This is often a sign of problems.\n');            
-        end
-        [infrow,infcol]=find(isinf(jacob));
-
-        if ~isempty(infrow)
-            fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains Inf. The problem is associated with:\n\n')
-            display_problematic_vars_Jacobian(infrow,infcol,M,ys,'static','evaluate_steady_state: ')
-        end
-        
-        if ~isreal(jacob)
-            [imagrow,imagcol]=find(abs(imag(jacob))>1e-15);
-            fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains imaginary parts. The problem arises from: \n\n')
-            display_problematic_vars_Jacobian(imagrow,imagcol,M,ys,'static','evaluate_steady_state: ')
-        end
-        
-        [nanrow,nancol]=find(isnan(jacob));
-        if ~isempty(nanrow)
-            fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains NaN. The problem is associated with:\n\n')
-            display_problematic_vars_Jacobian(nanrow,nancol,M,ys,'static','evaluate_steady_state: ')
+        if steadystate_flag
+            nan_indices_mult=find(isnan(resids(1:n_multipliers)));
+            if any(nan_indices_mult)
+                fprintf('evaluate_steady_state: The steady state results NaN for auxiliary equation %u.\n',nan_indices_mult);
+                fprintf('evaluate_steady_state: This is often a sign of problems.\n');
+            end
+            [infrow,infcol]=find(isinf(jacob));
+            
+            if ~isempty(infrow)
+                fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains Inf. The problem is associated with:\n\n')
+                display_problematic_vars_Jacobian(infrow,infcol,M,ys,'static','evaluate_steady_state: ')
+            end
+            
+            if ~isreal(jacob)
+                [imagrow,imagcol]=find(abs(imag(jacob))>1e-15);
+                fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains imaginary parts. The problem arises from: \n\n')
+                display_problematic_vars_Jacobian(imagrow,imagcol,M,ys,'static','evaluate_steady_state: ')
+            end
+            
+            [nanrow,nancol]=find(isnan(jacob));
+            if ~isempty(nanrow)
+                fprintf('\nevaluate_steady_state: The Jacobian of the dynamic model contains NaN. The problem is associated with:\n\n')
+                display_problematic_vars_Jacobian(nanrow,nancol,M,ys,'static','evaluate_steady_state: ')
+            end
+            
         end
 
     end
-- 
GitLab