From 44eae1300d537d0a4eadc09a01e4040838b57386 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Mon, 14 Oct 2019 09:30:05 +0200 Subject: [PATCH] trap plot_end_date larger than actual length of smoother --- matlab/plot_shock_decomposition.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matlab/plot_shock_decomposition.m b/matlab/plot_shock_decomposition.m index 4800e33b3..9fa356b1d 100644 --- a/matlab/plot_shock_decomposition.m +++ b/matlab/plot_shock_decomposition.m @@ -515,7 +515,11 @@ if ~isempty(options_.plot_shock_decomp.plot_init_date) a = find((initial_date:initial_date+b-1)==options_.plot_shock_decomp.plot_init_date); end if ~isempty(options_.plot_shock_decomp.plot_end_date) - b = find((initial_date:initial_date+b-1)==options_.plot_shock_decomp.plot_end_date); + if options_.plot_shock_decomp.plot_end_date<=(max(initial_date:initial_date+b-1)) + b = find((initial_date:initial_date+b-1)==options_.plot_shock_decomp.plot_end_date); + else + warning('You set plot_end_date larger than smoother size!!'); + end end z = z(:,:,a:b); % end crop data