diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m
index e82ae536f067cede5429f1051af96da83b62cff4..8fceebbe59a1225af7ed45ddae57d993464f0c1b 100644
--- a/matlab/dyn_first_order_solver.m
+++ b/matlab/dyn_first_order_solver.m
@@ -275,6 +275,12 @@ if nstatic > 0
     b11 = b(1:nstatic, nstatic+1:end);
     temp(:,index_m) = temp(:,index_m)-A(1:nstatic,:);
     temp = b10\(temp-b11*ghx);
+    if DynareOptions.debug
+        if any(any(~isfinite(temp)))
+            fprintf('\ndyn_first_order_solver: infinite/NaN elements encountered when solving for the static variables\n')
+            fprintf('dyn_first_order_solver: This often arises if there is a singularity.\n\n')
+        end
+    end
     ghx = [temp; ghx];
     temp = [];
 end