From 9a66f3ebd9819bc2739512811a838a5aed663ebe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stepan@adjemian.eu>
Date: Mon, 18 May 2020 12:21:43 +0200
Subject: [PATCH] Allow shocks with initval_file.

---
 matlab/perfect-foresight-models/make_ex_.m                | 4 +++-
 matlab/perfect-foresight-models/perfect_foresight_setup.m | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/matlab/perfect-foresight-models/make_ex_.m b/matlab/perfect-foresight-models/make_ex_.m
index 4f72590484..6bbb965976 100644
--- a/matlab/perfect-foresight-models/make_ex_.m
+++ b/matlab/perfect-foresight-models/make_ex_.m
@@ -42,7 +42,9 @@ end
 
 % Initialize oo_.exo_simul
 if isempty(M_.exo_histval)
-    if isempty(ex0_)
+    if options_.initval_file
+        % exo_simul provided by initval file
+    elseif isempty(ex0_)
         oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+options_.periods+M_.maximum_lead,1);
     else
         oo_.exo_simul = [ repmat(ex0_',M_.maximum_lag,1) ; repmat(oo_.exo_steady_state',options_.periods+M_.maximum_lead,1) ];
diff --git a/matlab/perfect-foresight-models/perfect_foresight_setup.m b/matlab/perfect-foresight-models/perfect_foresight_setup.m
index 45f6f2789d..8f59e4e9ba 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_setup.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_setup.m
@@ -64,7 +64,8 @@ if ~isempty(M_.det_shocks) && options_.periods<max([M_.det_shocks.periods])
     error('PERFECT_FORESIGHT_SETUP: Please check the declaration of the shocks or increase the value of the periods option.')
 end
 
+oo_ = make_ex_(M_,options_,oo_);
+
 if ~options_.initval_file
-    oo_ = make_ex_(M_,options_,oo_);
     oo_ = make_y_(M_,options_,oo_);
 end
-- 
GitLab