From 14819abb5f495fb661551046d6999890d1420a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 15 May 2014 17:58:34 +0200 Subject: [PATCH] Added specialized code for static models. --- matlab/utilities/dseries/from.m | 68 +++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/matlab/utilities/dseries/from.m b/matlab/utilities/dseries/from.m index 033cfc558..8a272873a 100644 --- a/matlab/utilities/dseries/from.m +++ b/matlab/utilities/dseries/from.m @@ -178,21 +178,27 @@ if isequal(length(equal_id),1) if length(assignedvariablename)>1 error('No more than one variable can be assigned!') end - % Check that the dynamic model for the endogenous variable is not forward looking. + % Check if the model is static start = regexpi(assignedvariablename{1},'\(t\)|\(t\-\d\)|\(t\+\d\)'); index = assignedvariablename{1}(start:end); assignedvariablename = assignedvariablename{1}(1:start-1); - indum = index2num(index); indva = strmatch(assignedvariablename, leadlagtable(:,1)); - if indum .^, / -> ./, * -> .*) + EXPRESSION = strrep(EXPRESSION,'^','.^'); + EXPRESSION = strrep(EXPRESSION,'*','.*'); + EXPRESSION = strrep(EXPRESSION,'/','./'); + % Do the job. Evaluate the static expression. + eval(sprintf('%s;',EXPRESSION)); end -% Do the job. Evaluate the recursion. -eval(sprintf('for t=%s:%s, %s; end',num2str(t1),num2str(t2),EXPRESSION)); - % Put assigned variable back in the caller workspace... eval(sprintf('assignin(''caller'', ''%s'', dseries(data(:,indva),y.init,y.name,y.tex));',assignedvariablename))