Fixed bug in name2index

Previously, the strings were concatenated, rendering calls to strmatch
wrong. Changed to cell arrays on which strmatch operates.
time-shift
Johannes Pfeifer 2013-04-29 23:17:11 +02:00
parent 749fff9dcb
commit fe6f63aa2e
1 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@ function i = name2index(options_, M_, estim_params_, type, name1, name2 )
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2008-2010 Dynare Team % Copyright (C) 2008-2013 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -64,7 +64,7 @@ if strcmpi(type,'StructuralShock')
else% Covariance matrix off-diagonal term else% Covariance matrix off-diagonal term
offset = nvx+nvn; offset = nvx+nvn;
try try
list_of_structural_shocks = [ M_.exo_names(estim_params_.corrx(:,1),:) , M_.exo_names(estim_params_.corrx(:,2),:) ]; list_of_structural_shocks = { M_.exo_names(estim_params_.corrx(:,1),:) , M_.exo_names(estim_params_.corrx(:,2),:) };
k1 = strmatch(name1,list_of_structural_shocks(:,1),'exact'); k1 = strmatch(name1,list_of_structural_shocks(:,1),'exact');
k2 = strmatch(name2,list_of_structural_shocks(:,2),'exact'); k2 = strmatch(name2,list_of_structural_shocks(:,2),'exact');
i = offset+intersect(k1,k2); i = offset+intersect(k1,k2);
@ -75,7 +75,7 @@ if strcmpi(type,'StructuralShock')
end end
if isempty(i) if isempty(i)
if isempty(i) if isempty(i)
disp(['The correlation between' name1 ' and ' name2 ' is not an estimated parameter!']) disp(['The correlation between ' name1 ' and ' name2 ' is not an estimated parameter!'])
return return
end end
end end
@ -95,7 +95,7 @@ if strcmpi(type,'MeasurementError')
else% Covariance matrix off-diagonal term else% Covariance matrix off-diagonal term
offset = nvx+nvn+ncx; offset = nvx+nvn+ncx;
try try
list_of_measurement_errors = [ M_.endo_names(estim_params_.corrn(:,1),:) , M_.endo_names(estim_params_.corrn(:,2),:) ]; list_of_measurement_errors = { M_.endo_names(estim_params_.corrn(:,1),:) , M_.endo_names(estim_params_.corrn(:,2),:) };
k1 = strmatch(name1,list_of_measurement_errors(:,1),'exact'); k1 = strmatch(name1,list_of_measurement_errors(:,1),'exact');
k2 = strmatch(name2,list_of_measurement_errors(:,2),'exact'); k2 = strmatch(name2,list_of_measurement_errors(:,2),'exact');
i = offset+intersect(k1,k2); i = offset+intersect(k1,k2);