From fd880a9387fe1487e005e7a8d71b8521d48d6f30 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 7 Feb 2019 19:02:22 +0100 Subject: [PATCH] gui: other simplifications/aesthetic changes --- matlab/+gui/+perfect_foresight/run.m | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/matlab/+gui/+perfect_foresight/run.m b/matlab/+gui/+perfect_foresight/run.m index ec621928f..5dbc39424 100644 --- a/matlab/+gui/+perfect_foresight/run.m +++ b/matlab/+gui/+perfect_foresight/run.m @@ -42,7 +42,7 @@ if nargout > 1 end %% Read JSON -jm = loadjson(json, 'SimplifyCell', 0); +jm = loadjson(json, 'SimplifyCell', 1); %% INITVAL instructions % initialize exogenous shocks to zero and compute initial steady state @@ -107,7 +107,8 @@ if isfield(jm, 'transitory_shocks') && ~isempty(jm.transitory_shocks) M_.exo_det_length = 0; end -if jm.nonanticipatedshockexist == 1 || jm.delayexist == 1 +if isfield(jm, 'unanticipated_shocks') && ~isempty(jm.unanticipated_shocks) ... + || isfield(jm, 'expected_date') && ~isempty(jm.expected_date) nonanticip = jm.nonanticipmatrix; rowindex = 1; firstsimul = 0; @@ -117,10 +118,24 @@ if jm.nonanticipatedshockexist == 1 || jm.delayexist == 1 % there are nonanticipated shocks to add at first period if nonanticip{rowindex}{4} == 0 % this is a current nonanticipated shock - M_.det_shocks = [ M_.det_shocks;struct('exo_det',0,'exo_id',(nonanticip{rowindex}{2}+1),'multiplicative',0,'periods',1:1,'value',nonanticip{rowindex}{7}) ]; + M_.det_shocks = [ ... + M_.det_shocks; ... + struct( ... + 'exo_det', 0, ... + 'exo_id', nonanticip{rowindex}{2}+1, ... + 'multiplicative', 0, ... + 'periods', 1:1, ... + 'value',nonanticip{rowindex}{7})]; else % this is a delayed nonanticipated shock - M_.det_shocks = [ M_.det_shocks;struct('exo_det',0,'exo_id',(nonanticip{rowindex}{2}+1),'multiplicative',0,'periods',(nonanticip{rowindex}{5}):(nonanticip{rowindex}{6}),'value',nonanticip{rowindex}{7}) ]; + M_.det_shocks = [ ... + M_.det_shocks; ... + struct( ... + 'exo_det', 0, ... + 'exo_id', nonanticip{rowindex}{2}+1, ... + 'multiplicative', 0, ... + 'periods', nonanticip{rowindex}{5}:nonanticip{rowindex}{6}, ... + 'value', nonanticip{rowindex}{7})]; end if nonanticip{rowindex+1}{1} ~= currentperiod % when we have tracked all first period shocks we can simulate