Hold on funciton for plotting irf togherther

I have a problem in plotting togherter the graph of irf after that I did a loop on matlab for changing the value of a variable. I use hold on function but it doesn’t work, I don’t understend why…
I attach here my work on dynare and my matlab loop.

phi_loop.m (557 Bytes)

home_tut33.mod (949 Bytes)

You did not define a list of variables. Try

%Plotting every variable in one graph
figure;
var_list_=M_.endo_names;
for j=1:length(var_list_)
    subplot(3,2,j);
    for i=1:length(phi_i)
        plot(results.(sprintf('phi%d',i)).irfs.(sprintf('%s_ea',char(var_list_(j)))));
        hold on;
        title(sprintf('%s_ea',char(var_list_(j))));
    end
    legend(strcat('phi = ',string(phi_i)));
    hold on;
    legend;
end

phi_loop.m (585 Bytes)

2 Likes

Thanks for answer me, but I don’t understand wich variables I have to insert there, and what means subplot(3,2,j)?
sorry for my ignorance, I’m new :slight_smile:

The above code will plot all variables. Regarding subplot, see https://de.mathworks.com/help/matlab/ref/subplot.html