From 9ddf10830f07814cd2bc4f960ec2bf9eb9a107c0 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Sun, 21 Jul 2013 00:02:09 +0200 Subject: [PATCH] Add debugging option to simul that allows for checking problems with exogenous variables --- matlab/simul.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/matlab/simul.m b/matlab/simul.m index 007a0d77b..c9fb8f896 100644 --- a/matlab/simul.m +++ b/matlab/simul.m @@ -79,6 +79,22 @@ end options_.scalv= 1 ; +if options_.debug + model_static = str2func([M_.fname,'_static']); + for ii=1:size(oo_.exo_simul,1) + [residual(:,ii)] = model_static(oo_.steady_state, oo_.exo_simul(ii,:),M_.params); + end + problematic_periods=find(any(isinf(residual)) | any(isnan(residual)))-M_.maximum_endo_lag; + if ~isempty(problematic_periods) + period_string=num2str(problematic_periods(1)); + for ii=2:length(problematic_periods) + period_string=[period_string, ', ', num2str(problematic_periods(ii))]; + end + fprintf('\n\nWARNING: Value for the exogenous variable(s) in period(s) %s inconsistent with the static model.\n',period_string); + fprintf('WARNING: Check for division by 0.\n') + end +end + if(options_.block) if(options_.bytecode) [info, oo_.endo_simul] = bytecode('dynamic');