Without the files to replicate the problem, it is impossible to answer.

# Q: combining IRFs into subplotted figures & iterating?

Thanks you for responding. Those are the files :

ssfriction_amenage.mod (10.5 KB)

ssfriction_fixe.mod (10.5 KB)

Have not had time to run the code… but did you try

```
plot(HOR, irf1,..other plot options); hold on;
plot(HOR, irf2...other plot options)
```

Currently, you are trying to plot HOR on the x axis with 2 variables on the yaxis,using a single plot command…that could explain the error. your syntax seems to be similar to the old plotyy command

https://www.mathworks.com/help/matlab/ref/plotyy.html

Another simple way to do it, would be

`plot([irf1 irf2])`

if they are of the same lengths…

Reuben

The last part should be

```
for ii=1:length(ending_cell)
HOR=1:options_.irf;
var={'lab','inv'};
figure
for jj=1:length(var)
subplot(1,2,jj)
eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
eval(['irf2.' var{1,jj},ending_cell{1,ii}]);
load irf1
load irf2
hold on
plot(HOR,[eval(['irf1.' var{1,jj},ending_cell{1,ii}])],'-k',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'--r','LineWidth',2)
title([var{1,jj}] )
end
end
```

looks like plot(x1,y1,x1,y2) works fine. just checked it.

Thank you so much. My model is working now.

Hi,

I am trying to combine IRFs of two models in one graph, but I am getting this error Undefined function or variable ‘epsilon_phi_X1’.

figure;

irf_epsilon_phi=[epsilon_phi_X1 epsilon_phi_X2];

subplot(3,3,1);

h=plot(irf_epsilon_phi);

set(h(1),‘color’,‘k’);

set(h(2),‘Marker’,’*’,‘color’,‘k’);

set(h(3),‘Marker’,‘o’,‘color’,‘k’);

axis tight;

title(‘epsilon_phi’)

You need to provide the codes.

Hello,

I solve the model with perfect foresight simulation, so I don’t have oo_.irfs in my results. When I plot the the simulated path of each model, I directly use the name of the variables (ex: plot(eval([‘100*(’ vari{1} ‘(X))’]) where vari is a vestor of the names of my variables). Now, in order to combine the plots of two models, I’m struggling to find where the endogenous variables are stored, so that I can call them and save them as it is done here for IRF1 and IRF2. I can see them in the workspace, but I don’t know how to get access to them.

Thank you for your help!

All perfect foresight results are stored in `oo_.endo_simul`

Hi there: I was wondering whether I could get some help in fixing this little error: I don´t get the plots because they do not have the same lenght. I though Matlab would adjust this. The impulse responses are both for same variables. Here is my code:

ERROR

Many thanks

I would need to see the codes/files to replicate the issue.

Thank you for your help. Please, find attached both files and the m.file for the combined impulse responses. For know I would just like to combine responses for eps_k

combi1.m (842 Bytes)

departshock1.mod (3.1 KB)

macroproject.mod (3.4 KB)

It should be

```
dynare macroproject.mod;
irf1 = oo_.irfs;
save macroprojectresponses.mat irf1;
dynare departshock1.mod;
irf2 = oo_.irfs;
save departshock1results.mat irf2;
load('macroprojectresponses.mat','irf1');
load('departshock1results.mat','irf2');
ending_cell={'_eps_k'};
%'y', 'dp', 'cs', 'cb', 'h', 'hs', 'r', 'qh', 'qz'
for ii=1:length(ending_cell)
HOR=1:options_.irf;
var={'y', 'dp', 'cs', 'cb'};
figure
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(['irf1.' var{1,jj},ending_cell{1,ii}])],'-k',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'--r','LineWidth',2) ;
title([var{1,jj}] )
end
end
```