diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 933321d9b..c1710420a 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -557,7 +557,10 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha if ~options_.nograph [nbplt,nr,nc,lr,lc,nstar] = pltorg(M_.exo_nbr); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) - fidTeX = fopen([M_.fname '_SmoothedShocks.tex'],'w'); + if ~exist([M_.fname '/graphs'],'dir') + mkdir(M_.fname,'graphs'); + end + fidTeX = fopen([M_.fname, '/graphs/' M_.fname '_SmoothedShocks.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation_1.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -604,14 +607,14 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha end title(name,'Interpreter','none') end - dyn_saveas(fh,[M_.fname '_SmoothedShocks' int2str(plt)],options_.nodisplay,options_.graph_format); + dyn_saveas(fh,[M_.fname, '/graphs/' M_.fname '_SmoothedShocks' int2str(plt)],options_.nodisplay,options_.graph_format); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for jj = 1:nstar0 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_SmoothedShocks%s}\n',options_.figures.textwidth*min(i/nc,1),M_.fname,int2str(plt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_SmoothedShocks%s}\n',options_.figures.textwidth*min(i/nc,1),[M_.fname, '/graphs/' M_.fname],int2str(plt)); fprintf(fidTeX,'\\caption{Smoothed shocks.}'); fprintf(fidTeX,'\\label{Fig:SmoothedShocks:%s}\n',int2str(plt)); fprintf(fidTeX,'\\end{figure}\n'); @@ -636,7 +639,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha if ~options_.nograph [nbplt,nr,nc,lr,lc,nstar] = pltorg(number_of_plots_to_draw); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) - fidTeX = fopen([M_.fname '_SmoothedObservationErrors.tex'],'w'); + fidTeX = fopen([M_.fname, '/graphs/' M_.fname '_SmoothedObservationErrors.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation_1.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -684,14 +687,14 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha end title(name,'Interpreter','none') end - dyn_saveas(fh,[M_.fname '_SmoothedObservationErrors' int2str(plt)],options_.nodisplay,options_.graph_format); + dyn_saveas(fh,[M_.fname, '/graphs/' M_.fname '_SmoothedObservationErrors' int2str(plt)],options_.nodisplay,options_.graph_format); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for jj = 1:nstar0 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_SmoothedObservationErrors%s}\n',options_.figures.textwidth*min(i/nc,1),M_.fname,int2str(plt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_SmoothedObservationErrors%s}\n',options_.figures.textwidth*min(i/nc,1),[M_.fname, '/graphs/' M_.fname],int2str(plt)); fprintf(fidTeX,'\\caption{Smoothed observation errors.}'); fprintf(fidTeX,'\\label{Fig:SmoothedObservationErrors:%s}\n',int2str(plt)); fprintf(fidTeX,'\\end{figure}\n'); @@ -711,7 +714,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha if ~options_.nograph [nbplt,nr,nc,lr,lc,nstar] = pltorg(n_varobs); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) - fidTeX = fopen([M_.fname '_HistoricalAndSmoothedVariables.tex'],'w'); + fidTeX = fopen([M_.fname, '/graphs/' M_.fname '_HistoricalAndSmoothedVariables.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation_1.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -759,14 +762,14 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha end title(name,'Interpreter','none') end - dyn_saveas(fh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)],options_.nodisplay,options_.graph_format); + dyn_saveas(fh,[M_.fname, '/graphs/' M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)],options_.nodisplay,options_.graph_format); if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for jj = 1:nstar0 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_HistoricalAndSmoothedVariables%s}\n',options_.figures.textwidth*min(i/nc,1),M_.fname,int2str(plt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_HistoricalAndSmoothedVariables%s}\n',options_.figures.textwidth*min(i/nc,1),[M_.fname, '/graphs/' M_.fname],int2str(plt)); fprintf(fidTeX,'\\caption{Historical and smoothed variables.}'); fprintf(fidTeX,'\\label{Fig:HistoricalAndSmoothedVariables:%s}\n',int2str(plt)); fprintf(fidTeX,'\\end{figure}\n'); diff --git a/matlab/mode_check.m b/matlab/mode_check.m index ca0bb96ab..1389d1737 100644 --- a/matlab/mode_check.m +++ b/matlab/mode_check.m @@ -78,7 +78,10 @@ end [nbplt,nr,nc,lr,lc,nstar] = pltorg(length(x)); if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format))) - fidTeX = fopen([Model.fname '_CheckPlots.tex'],'w'); + if ~exist([Model.fname filesep 'graphs'],'dir') + mkdir(Model.fname,'graphs'); + end + fidTeX = fopen([Model.fname, '/graphs/', Model.fname '_CheckPlots.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by mode_check.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -202,7 +205,7 @@ for plt = 1:nbplt text(0.25,0.5,'log-post') text(0.69,0.5,'log-lik kernel') end - dyn_saveas(hh,[ Model.fname '_CheckPlots' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format); + dyn_saveas(hh,[Model.fname, '/graphs/', Model.fname '_CheckPlots' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format); if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format))) % TeX eps loader file fprintf(fidTeX,'\\begin{figure}[H]\n'); @@ -210,7 +213,7 @@ for plt = 1:nbplt fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_CheckPlots%s}\n',DynareOptions.figures.textwidth*min(k/nc,1),Model.fname,int2str(plt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_CheckPlots%s}\n',DynareOptions.figures.textwidth*min(k/nc,1),[Model.fname, '/graphs/',Model.fname],int2str(plt)); fprintf(fidTeX,'\\caption{Check plots.}'); fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n',int2str(plt)); fprintf(fidTeX,'\\end{figure}\n'); diff --git a/matlab/plot_priors.m b/matlab/plot_priors.m index 2b2fc83f6..0a70a6b91 100644 --- a/matlab/plot_priors.m +++ b/matlab/plot_priors.m @@ -37,7 +37,10 @@ npar = length(bayestopt_.p1); [nbplt,nr,nc,lr,lc,nstar] = pltorg(npar); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) - fidTeX = fopen([M_.fname '_Priors.tex'],'w'); + if ~exist([M_.fname '/graphs'],'dir') + mkdir(M_.fname,'graphs'); + end + fidTeX = fopen([M_.fname, '/graphs/' M_.fname '_Priors.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by plot_priors.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -70,14 +73,14 @@ for plt = 1:nbplt title(nam,'Interpreter','none') drawnow end - dyn_saveas(hplt,[M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format); + dyn_saveas(hplt,[M_.fname, '/graphs/' M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for jj = 1:nstar0 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); end fprintf(fidTeX,'\\centering\n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_Priors%s}\n',options_.figures.textwidth*min(index/nc,1),M_.fname,int2str(plt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_Priors%s}\n',options_.figures.textwidth*min(index/nc,1),[M_.fname, '/graphs/' M_.fname],int2str(plt)); fprintf(fidTeX,'\\caption{Priors.}'); fprintf(fidTeX,'\\label{Fig:Priors:%s}\n',int2str(plt)); fprintf(fidTeX,'\\end{figure}\n'); diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m index 190796b28..bcfbadd11 100644 --- a/matlab/stoch_simul.m +++ b/matlab/stoch_simul.m @@ -203,7 +203,10 @@ if options_.irf var_listTeX = M_.endo_names_tex(i_var); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) - fidTeX = fopen([M_.fname '_IRF.tex'],'w'); + if ~exist([M_.fname '/graphs'],'dir') + mkdir(M_.fname,'graphs'); + end + fidTeX = fopen([M_.fname, '/graphs/' M_.fname '_IRF.tex'],'w'); fprintf(fidTeX,'%% TeX eps-loader file generated by stoch_simul.m (Dynare).\n'); fprintf(fidTeX,['%% ' datestr(now,0) '\n']); fprintf(fidTeX,' \n'); @@ -290,14 +293,14 @@ if options_.irf remove_fractional_xticks; title(deblank(mylist(j,:)),'Interpreter','none'); end - dyn_saveas(hh,[M_.fname '_IRF_' tit{i}],options_.nodisplay,options_.graph_format); + dyn_saveas(hh,[M_.fname, '/graphs/' M_.fname '_IRF_' tit{i}],options_.nodisplay,options_.graph_format); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for j = 1:number_of_plots_to_draw fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{$%s$}\n',deblank(mylist(j,:)),deblank(mylistTeX(j,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s}\n',options_.figures.textwidth*min(j/nc,1),M_.fname,tit{i}); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s}\n',options_.figures.textwidth*min(j/nc,1),[M_.fname, '/graphs/' M_.fname],tit{i}); fprintf(fidTeX,'\\caption{Impulse response functions (orthogonalized shock to $%s$).}\n',titTeX{i}); fprintf(fidTeX,'\\label{Fig:IRF:%s}\n', tit{i}); fprintf(fidTeX,'\\end{figure}\n'); @@ -322,14 +325,14 @@ if options_.irf remove_fractional_xticks title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter','none'); end - dyn_saveas(hh,[ M_.fname '_IRF_' tit{i} int2str(fig)],options_.nodisplay,options_.graph_format); + dyn_saveas(hh,[M_.fname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(fig)],options_.nodisplay,options_.graph_format); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for j = 1:nstar fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{$%s$}\n',deblank(mylist((fig-1)*nstar+j,:)),deblank(mylistTeX((fig-1)*nstar+j,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n',options_.figures.textwidth*min(plt/nc,1),M_.fname,tit{i},int2str(fig)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n',options_.figures.textwidth*min(plt/nc,1),[M_.fname, '/graphs/' M_.fname],tit{i},int2str(fig)); if options_.relative_irf fprintf(fidTeX,'\\caption{Relative impulse response functions (orthogonalized shock to $%s$).}', titTeX{i}); else @@ -353,14 +356,14 @@ if options_.irf remove_fractional_xticks title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter','none'); end - dyn_saveas(hh,[ M_.fname '_IRF_' tit{i} int2str(nbplt) ],options_.nodisplay,options_.graph_format); + dyn_saveas(hh,[M_.fname, '/graphs/' M_.fname '_IRF_' tit{i} int2str(nbplt) ],options_.nodisplay,options_.graph_format); if TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'\\begin{figure}[H]\n'); for j = 1:m fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{$%s$}\n',deblank(mylist((nbplt-1)*nstar+j,:)),deblank(mylistTeX((nbplt-1)*nstar+j,:))); end fprintf(fidTeX,'\\centering \n'); - fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n',options_.figures.textwidth*min(m/lc,1),M_.fname,tit{i},int2str(nbplt)); + fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n',options_.figures.textwidth*min(m/lc,1),[M_.fname, '/graphs/' M_.fname],tit{i},int2str(nbplt)); if options_.relative_irf fprintf(fidTeX,'\\caption{Relative impulse response functions (orthogonalized shock to $%s$).}', titTeX{i}); else