Thanks for the help, this code seems to work. However I had one last question. I would like to change the sub plot titles which currently appear as variable names. I tried the following:
dynare WealthShare4.mod;
rhos=[0.5 1.5 2.5];
for ii=1:length(rhos)
set_param_value('PSI',rhos(ii));
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);
if ~info
irf_cell{ii}=oo_.irfs;
end
end
shock_ending_cell={'g'};
var_names={'dws','rdiff','e'};
for shock_iter=1:length(shock_ending_cell)
figure('Name',shock_ending_cell{shock_iter})
for var_iter=1:length(var_names)
subplot(2,2,var_iter)
plot(1:options_.irf,irf_cell{1}.([var_names{var_iter},'_',shock_ending_cell{shock_iter}]))
legend({'$\psi=0.5$','$\psi=1.5$','$\psi=2.5$'},'Interpreter','latex')
title('$\tilde{W}_{t}$', 'Interpreter','latex', 'fontweight', 'bold', 'Units', 'normalized', 'Position', [0.5, 1.05, 0]);
hold on
plot(1:options_.irf,irf_cell{2}.([var_names{var_iter},'_',shock_ending_cell{shock_iter}]))
legend({'$\psi=0.5$','$\psi=1.5$','$\psi=2.5$'},'Interpreter','latex')
title('$\mathcal{E}_{t}$', 'Interpreter','latex', 'fontweight', 'bold', 'Units', 'normalized', 'Position', [0.5, 1.05, 0]);
end
end
When I do this, it just changes the titles of both subplots to the last title in the code. Do you have any idea on how I can change the subplot titles in this loop to reflect the two corresponding titles I’ve written in latex code?