diff --git a/tests/practicing/datasaver.m b/tests/practicing/datasaver.m index dcee78ca4..2c72e20e1 100644 --- a/tests/practicing/datasaver.m +++ b/tests/practicing/datasaver.m @@ -1,15 +1,29 @@ -% Copyright (C) 2001 Michel Juillard -% -function dynatype (s,var_list) -% DYNATYPE : DYNATYPE ( [ 'filename' ] ) -% This optional command saves the simulation -% results in a text file. The name of each -% variable preceeds the corresponding results. -% This command must follow SIMUL. +function datasaver (s,var_list) +% datasaver saves variables simulated by Dynare +% INPUT +% s: a string containing the name of the destination *.m file +% var_list: a character matrix containting the name of the variables +% to be saved (optional, default: all endogenous variables) +% OUTPUT +% none +% This is part of the examples included in F. Barillas, R. Colacito, +% S. Kitao, C. Matthes, T. Sargent and Y. Shin (2007) "Practicing +% Dynare". + +% Modified by M. Juillard to make it also compatible with Dynare +% version 4 (12/4/07) + -global lgy_ lgx_ y_ endo_nbr +global lgy_ lgx_ y_ endo_nbr M_ oo_ + +% test and adapt for Dynare version 4 +if isempty(lgy_) + lgy_ = M_.endo_names; + lgx_ + M_.exo_names; + y_ = oo_.endo_simul; + endo_nbr = M_.endo_nbr; +end -%fid=fopen([s,'.m'],'w') ; sm=[s,'.m']; fid=fopen(sm,'w') ;