Home > matlab > formdata.m

formdata

PURPOSE ^

function formdata(fname,date)

SYNOPSIS ^

function formdata(fname,date)

DESCRIPTION ^

 function formdata(fname,date)
 store endogenous and exogenous variables in a "FRM" TROLL text format file
 INPUT
   fname: name of the FRM file
   date:  the date of first observation (i.e. 2007A for an annual dataset)
 OUTPUT
   none
 ALGORITHM
   none
 SPECIAL REQUIREMENT
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function formdata(fname,date)
0002 % function formdata(fname,date)
0003 % store endogenous and exogenous variables in a "FRM" TROLL text format file
0004 % INPUT
0005 %   fname: name of the FRM file
0006 %   date:  the date of first observation (i.e. 2007A for an annual dataset)
0007 % OUTPUT
0008 %   none
0009 % ALGORITHM
0010 %   none
0011 % SPECIAL REQUIREMENT
0012 %   none
0013 
0014 % Copyright (C) 2007-2010 Dynare Team
0015 %
0016 % This file is part of Dynare.
0017 %
0018 % Dynare is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % Dynare is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 global M_ oo_
0032 fid = fopen([fname '_endo.frm'],'w');
0033 n=size(oo_.endo_simul,1);
0034 t=size(oo_.endo_simul,2);
0035 SN=upper(cellstr(M_.endo_names));
0036 for i=1:n
0037     str=char(SN(i));
0038     fprintf(fid,'USER: x x DATAFILE: x %s\n',str);
0039     fprintf(fid,'PER: 1    YEAR: %s   FRAC: 1   NOBS: %d   CLINES: 0   DLINES: ???\n',date,t);
0040     fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.endo_simul(i,1:floor(t/4)*4),floor(t/4),4));
0041     if(floor(t/4)*4<t)
0042         switch(t-floor(t/4)*4)
0043           case 1
0044             fprintf(fid,'%10.5f\n',oo_.endo_simul(i,floor(t/4)*4+1:t));
0045           case 2
0046             fprintf(fid,'%10.5f %10.5f\n',oo_.endo_simul(i,floor(t/4)*4+1:t));
0047           case 3
0048             fprintf(fid,'%10.5f %10.5f %10.5f\n',oo_.endo_simul(i,floor(t/4)*4+1:t));
0049         end;
0050         %else
0051         %    fprintf(fid,'\n');
0052     end;
0053 end;
0054 fclose(fid);
0055 
0056 fid = fopen([fname '_exo.frm'],'w');
0057 n=size(oo_.exo_simul,2);
0058 t=size(oo_.exo_simul,1);
0059 SN=upper(cellstr(M_.exo_names));
0060 for i=1:n
0061     str=char(SN(i));
0062     fprintf(fid,'USER: x x DATAFILE: x %s\n',str);
0063     fprintf(fid,'PER: 1    YEAR: %s   FRAC: 1   NOBS: %d   CLINES: 0   DLINES: ???\n',date,t);
0064     fprintf(fid,'%10.5f %10.5f %10.5f %10.5f\n',reshape(oo_.exo_simul(1:floor(t/4)*4,i),floor(t/4),4));
0065     if(floor(t/4)*4<t)
0066         switch(t-floor(t/4)*4)
0067           case 1
0068             fprintf(fid,'%10.5f\n',oo_.exo_simul(floor(t/4)*4+1:t,i)');
0069           case 2
0070             fprintf(fid,'%10.5f %10.5f\n',oo_.exo_simul(floor(t/4)*4+1:t,i)');
0071           case 3
0072             fprintf(fid,'%10.5f %10.5f %10.5f\n',oo_.exo_simul(floor(t/4)*4+1:t,i)');
0073         end;
0074         %else
0075         %    fprintf(fid,'\n');
0076     end;
0077 end;
0078 fclose(fid);
0079 return;

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005