diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m
index 76f2b69dcd45e579f5ceca3436149df7d6efee82..5d1969313d0924f75695a688afa4adb8ee9468f6 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m
@@ -68,6 +68,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
     skipline()
     
     % Disable warnings if homotopy
+    warning_old_state = warning;
     warning off all
     % Do not print anything
     oldverbositylevel = options_.verbosity;
@@ -147,7 +148,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
     fprintf('++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n')
     skipline()
     options_.verbosity = oldverbositylevel;
-    warning on all
+    warning(warning_old_state);
 end
 
 if oo_.deterministic_simulation.status == 1