From ce9bb2f09d23684043146bd7891274d2374891c6 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 6 Dec 2021 11:15:20 +0100 Subject: [PATCH] make_ex_.m: gracefully exit if user attempts to set non-existent period 0 --- matlab/perfect-foresight-models/make_ex_.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matlab/perfect-foresight-models/make_ex_.m b/matlab/perfect-foresight-models/make_ex_.m index 6f3e7dfa9..13663cffa 100644 --- a/matlab/perfect-foresight-models/make_ex_.m +++ b/matlab/perfect-foresight-models/make_ex_.m @@ -10,7 +10,7 @@ function oo_ = make_ex_(M_, options_, oo_) % OUTPUTS % - oo_ [struct] Updated dynare results structure -% Copyright (C) 1996-2020 Dynare Team +% Copyright (C) 1996-2021 Dynare Team % % This file is part of Dynare. % @@ -78,6 +78,9 @@ end % Add temporary shocks if isfield(M_, 'det_shocks') + if ~isempty(M_.det_shocks) && any([M_.det_shocks.periods]==0) && ~M_.maximum_lag + error('make_ex_: The model does not have lags, so you cannot set values for period 0'); %leads are taken care of by preprocessor + end for i = 1:length(M_.det_shocks) k = M_.det_shocks(i).periods + M_.maximum_lag; ivar = M_.det_shocks(i).exo_id;