
clear,clc

% Run and collect dynare outputs

dynare tank_cw;
irf1 = oo_.irfs;
save tank_cw_results.mat irf1;

dynare tankcw1;
irf2 = oo_.irfs;
save tankcw1_results.mat irf2;
load('tank_cw_results.mat', 'irf1');
load('tankcw1_results.mat', 'irf2');

ending_cell={'var eps'};

for ii=1:length(ending_cell)
    HOR=1:options_.irf;
    var={'n', 'nW', 'w', 'c', 'cC', 'cW', 'rn', 'r', 'pi', 'b', 'bC', 'bW', 't', 'g', 'd', 'csl', 'chl', 'bsl', 'bhl', 'ls', 'ZC', 'ZW'}; % variables to be plotted as called in Dynare
   fig(ii)= figure('Name',['Shock to',sprintf(ending_cell{1,ii})],'NumberTitle','off');
    % plot the model variables 
    for jj=1:length(var)
        subplot(2,2,jj)
        eval(['irf1' var{1,jj},ending_cell{1,ii}]);
        eval(['irf2' var{1,jj},ending_cell{1,ii}]);     
        hold on
        plot(HOR,[eval(['irf2' var{1,jj},ending_cell{1,ii}])],HOR,[eval(['irf1' var{1,jj},ending_cell{1,ii}])],'LineWidth',1.3);      
        xlim([1 options_.irf]);
        hline = refline(0, 0);
        title([var{1,jj}] )
    end
    
    legend('Model1', 'Model2', 'AutoUpdate','off')
   
end



