Commit 8ff680b0 authored by michel's avatar michel
Browse files

made it possible for data file name to contain a pathname


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2389 ac1d8469-bf42-47a9-8791-bf33cf982152
parent c98d175e
......@@ -34,6 +34,14 @@ function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sh
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
old_pwd = cd;
[path_name_02,file_name_02,ext_name_02] = fileparts(file_name_01);
if ~isempty(path_name_02)
file_name_01 = [file_name_02, ext_name_02];
cd(path_name_02)
end
dyn_size_01 = size(dyn_data_01,1);
var_size_01 = size(var_names_01,1);
if exist(file_name_01)
......@@ -43,6 +51,7 @@ function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sh
for dyn_i_01=1:var_size_01
dyn_tmp_01 = eval(var_names_01(dyn_i_01,:));
if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
cd(old_pwd)
error('data size is too large')
end
dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
......@@ -53,6 +62,7 @@ function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sh
for dyn_i_01=1:var_size_01
dyn_tmp_01 = s.(deblank(var_names_01(dyn_i_01,:)));
if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
cd(old_pwd)
error('data size is too large')
end
dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
......@@ -64,12 +74,15 @@ function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sh
iv = strmatch(var_names_01(dyn_i_01,:),raw(1,:),'exact');
dyn_tmp_01 = [raw{2:end,iv}]';
if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
cd(old_pwd)
error('data size is too large')
end
dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
end
else
cd(old_pwd)
error(['Can''t find datafile: ' file_name_01 ]);
end
cd(old_pwd)
disp(sprintf('Loading %d observations from %s\n',...
size(dyn_data_01,1),file_name_02))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment