From a9c747b5f6eaa5e109210a332b5e552e3a387cd8 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Wed, 5 Feb 2020 21:18:25 +0100
Subject: [PATCH] imcforecast.m: make sure that draw index for CIs stays within
 feasible bounds

(cherry picked from commit 1d1c0ab829d9d0d5498378b2a019a3b6b5b34c16)
---
 matlab/imcforecast.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/matlab/imcforecast.m b/matlab/imcforecast.m
index ddb78b6c80..ad0af8f82b 100644
--- a/matlab/imcforecast.m
+++ b/matlab/imcforecast.m
@@ -257,8 +257,8 @@ mFORCS1 = mean(FORCS1,3);
 mFORCS1_shocks = mean(FORCS1_shocks,3);
 
 tt = (1-options_cond_fcst.conditional_forecast.conf_sig)/2;
-t1 = round(options_cond_fcst.replic*tt);
-t2 = round(options_cond_fcst.replic*(1-tt));
+t1 = max(1,round(options_cond_fcst.replic*tt));
+t2 = min(options_cond_fcst.replic,round(options_cond_fcst.replic*(1-tt)));
 
 forecasts.controlled_variables = constrained_vars;
 forecasts.instruments = options_cond_fcst.controlled_varexo;
-- 
GitLab