# Q: combining IRFs into subplotted figures & iterating?

**URL:** <https://forum.dynare.org/t/q-combining-irfs-into-subplotted-figures-iterating/3609>\
**Category:** Stochastic simulations\
**Created:** [8 January 2014 13:21 UTC](https://forum.dynare.org/t/q-combining-irfs-into-subplotted-figures-iterating/3609 "2014-01-08T13:21:14Z")\
**Posts on this page:** 1\
**Showing post:** 66

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [22 May 2021 17:47 UTC](https://forum.dynare.org/t/q-combining-irfs-into-subplotted-figures-iterating/3609/66 "2021-05-22T17:47:15Z")

</div>

Use

```auto
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;

ending_cell={'_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'}; % 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(5,5,jj)
        hold on
        plot(HOR,irf2.([var{1,jj},ending_cell{1,ii}]),HOR,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

```

---

_[View the full topic](https://forum.dynare.org/t/q-combining-irfs-into-subplotted-figures-iterating/3609)._
