From 0d0af077f5b291329d7547b802bd1e68db21a995 Mon Sep 17 00:00:00 2001 From: Ferhat Mihoubi <ferhat.mihoubi@univ-evry.fr> Date: Fri, 12 Feb 2010 10:58:10 +0100 Subject: [PATCH] Bugs corrected: exogenous variable are read from and external file if oo_.exo_simul is not completely filled => allows for shocks. (cherry picked from commit e4667489930820ae1b7279fba5dd1e179c7dbd06) --- matlab/read_data_.m | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/matlab/read_data_.m b/matlab/read_data_.m index 3f81486d09..99ffe7faa6 100644 --- a/matlab/read_data_.m +++ b/matlab/read_data_.m @@ -31,33 +31,38 @@ function read_data_ 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')]; + +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); + 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); 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')]; +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); + 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); 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); -- GitLab