


function initvalf(fname_)
Reads an initial path from the 'fname_' file for exogenous and endogenous variables
INPUTS
fname_: name of the function or file containing the data
OUTPUTS
none
SPECIAL REQUIREMENTS
All variables local to this function have an underscore appended to
their name, to minimize clashes with model variables loaded by this function.

0001 function initvalf(fname_) 0002 % function initvalf(fname_) 0003 % 0004 % Reads an initial path from the 'fname_' file for exogenous and endogenous variables 0005 % 0006 % INPUTS 0007 % fname_: name of the function or file containing the data 0008 % 0009 % OUTPUTS 0010 % none 0011 % 0012 % SPECIAL REQUIREMENTS 0013 % All variables local to this function have an underscore appended to 0014 % their name, to minimize clashes with model variables loaded by this function. 0015 0016 % Copyright (C) 2003-2010 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 global M_ oo_ options_ 0034 0035 series_ = 1; 0036 if exist(fname_) == 2 0037 eval(fname_); 0038 elseif exist([fname_ '.xls']) == 2 0039 [data_,names_v_]=xlsread([fname_ '.xls']); 0040 series_ = 0; 0041 elseif exist([fname_ '.mat']) == 2 0042 load(fname_); 0043 end 0044 0045 options_.initval_file = 1; 0046 oo_.endo_simul = []; 0047 oo_.exo_simul = []; 0048 0049 for i_=1:size(M_.endo_names,1) 0050 if series_ == 1 0051 x_ = eval(M_.endo_names(i_,:)); 0052 oo_.endo_simul = [oo_.endo_simul; x_']; 0053 else 0054 k_ = strmatch(upper(M_.endo_names(i_,:)),names_v_,'exact'); 0055 if isempty(k_) 0056 error(['INITVAL_FILE: ' M_.endo_names(i_,:) ' not found']) 0057 end 0058 x_ = data_(:,k_); 0059 oo_.endo_simul = [oo_.endo_simul; x_']; 0060 end 0061 end 0062 0063 for i_=1:size(M_.exo_names,1) 0064 if series_ == 1 0065 x_ = eval(M_.exo_names(i_,:) ); 0066 oo_.exo_simul = [oo_.exo_simul x_]; 0067 else 0068 k_ = strmatch(upper(M_.exo_names(i_,:)),names_v_,'exact'); 0069 if isempty(k_) 0070 error(['INITVAL_FILE: ' M_.exo_names(i_,:) ' not found']) 0071 end 0072 x_ = data_(:,k_); 0073 oo_.exo_simul = [oo_.exo_simul x_]; 0074 end 0075 end