1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
function read_data_()
% function read_data_
% reads endogenous and exogenous variables from a text file
% Used by datafile option in simulate
%
% INPUT
% none
%
% OUTPUT
% none
%
% SPECIAL REQUIREMENT
% none
% Copyright (C) 2007-2012 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global options_ M_ oo_;
dname= options_.datafile;
if size(oo_.endo_simul,2) < M_.maximum_lag+M_.maximum_lead+options_.periods
fid = fopen([dname '_endo.dat'],'r');
names_line = fgetl(fid);
allVariables = '';
positions = ones(0);
while (any(names_line))
[chopped,names_line] = strtok(names_line);
if isempty(allVariables)
allVariables = chopped;
else
allVariables = char(allVariables, chopped);
end
positions = [positions ; strmatch(chopped,M_.endo_names,'exact')];
end
Values=fscanf(fid,'%f',inf);
Values=reshape(Values,M_.orig_endo_nbr,size(Values,1)/M_.orig_endo_nbr);
oo_.endo_simul=[Values(positions,:); kron(oo_.steady_state((M_.orig_endo_nbr+1) : M_.endo_nbr , 1) , ones(1 , size(Values, 2)))];
fclose(fid);
end
if size(oo_.exo_simul,1) < M_.maximum_lag+M_.maximum_lead+options_.periods
fid = fopen([dname '_exo.dat'],'r');
names_line = fgetl(fid);
allVariables = '';
positions = ones(0);
while (any(names_line))
[chopped,names_line] = strtok(names_line);
if isempty(allVariables)
allVariables = chopped;
else
allVariables = char(allVariables, chopped);
end
positions = [positions ; strmatch(chopped,M_.exo_names,'exact')];
end
Values=fscanf(fid,'%f',inf);
Values=reshape(Values,M_.exo_nbr,size(Values,1)/M_.exo_nbr);
oo_.exo_simul=(Values(positions,:))';
fclose(fid);
end
%disp([allVariables M_.endo_names]);
%disp(positions);
end
|