diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m
index 0035bd7feeae9f199f71594f05990b1a4b943eee..3b8814d0ca988d4b85ae731a5fb6b62f7537d1b9 100644
--- a/matlab/evaluate_steady_state_file.m
+++ b/matlab/evaluate_steady_state_file.m
@@ -99,6 +99,10 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
             info(2) = residuals'*residuals;
             return
         end
+        if any(isnan(residuals))
+            info(1) = 22;
+            return
+        end
     elseif ~isempty(options.steadystate_partial)
         ssvar = options.steadystate_partial.ssvar;
         nov   = length(ssvar);
diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m
index efbbb7c9ccdf96524930fc0026a93b7a099afc1e..8b2144651c4ec37ef0bc2343c464df1a87604bb5 100644
--- a/matlab/stoch_simul.m
+++ b/matlab/stoch_simul.m
@@ -136,7 +136,8 @@ end
 
 if options_.periods > 0 && ~PI_PCL_solver
     if options_.periods <= options_.drop
-        disp(['STOCH_SIMUL error: The horizon of simulation is shorter than the number of observations to be dropped'])
+        fprintf('\nSTOCH_SIMUL error: The horizon of simulation is shorter than the number of observations to be dropped.\n')
+        fprintf('STOCH_SIMUL error: Either increase options_.periods or decrease options_.drop.\n')
         options_ =options_old;
         return
     end