2007-06-01 13:43:49 +02:00
|
|
|
function read_data_
|
2008-01-28 18:02:08 +01:00
|
|
|
|
2007-06-01 13:43:49 +02:00
|
|
|
% function read_data_
|
2008-01-28 18:02:08 +01:00
|
|
|
% reads endogenous and exogenous variables from a text file
|
2007-06-01 13:43:49 +02:00
|
|
|
% Used by datafile option in simulate
|
2008-01-28 18:02:08 +01:00
|
|
|
%
|
2007-06-01 13:43:49 +02:00
|
|
|
% INPUT
|
|
|
|
% none
|
2008-01-28 18:02:08 +01:00
|
|
|
%
|
2007-06-01 13:43:49 +02:00
|
|
|
% OUTPUT
|
|
|
|
% none
|
2008-01-28 18:02:08 +01:00
|
|
|
%
|
2007-06-01 13:43:49 +02:00
|
|
|
% SPECIAL REQUIREMENT
|
|
|
|
% none
|
|
|
|
%
|
2008-01-28 18:02:08 +01:00
|
|
|
% part of DYNARE, copyright Dynare Team (2007-2008)
|
2007-06-01 13:43:49 +02:00
|
|
|
% Gnu Public License.
|
2008-01-28 18:02:08 +01:00
|
|
|
|
2007-06-01 13:43:49 +02:00
|
|
|
global options_ M_ oo_;
|
|
|
|
dname= options_.datafile;
|
|
|
|
fid = fopen([dname '_endo.dat'],'r');
|
|
|
|
names_line = fgetl(fid);
|
|
|
|
allVariables = '';
|
|
|
|
positions = ones(0);
|
|
|
|
while (any(names_line))
|
|
|
|
[chopped,names_line] = strtok(names_line);
|
|
|
|
allVariables = strvcat(allVariables, chopped);
|
|
|
|
positions = [positions ; strmatch(chopped,M_.endo_names,'exact')];
|
|
|
|
end
|
|
|
|
Values=fscanf(fid,'%f',inf);
|
|
|
|
Values=reshape(Values,M_.endo_nbr,size(Values,1)/M_.endo_nbr);
|
|
|
|
oo_.endo_simul=Values(positions,:);
|
|
|
|
fclose(fid);
|
|
|
|
|
|
|
|
fid = fopen([dname '_exo.dat'],'r');
|
|
|
|
names_line = fgetl(fid);
|
|
|
|
allVariables = '';
|
|
|
|
positions = ones(0);
|
|
|
|
while (any(names_line))
|
|
|
|
[chopped,names_line] = strtok(names_line);
|
|
|
|
allVariables = strvcat(allVariables, chopped);
|
|
|
|
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);
|
|
|
|
%disp([allVariables M_.endo_names]);
|
|
|
|
%disp(positions);
|
|
|
|
|
|
|
|
end
|