diff --git a/matlab/utilities/dseries/from.m b/matlab/utilities/dseries/from.m index 4fa830917..404c408b5 100644 --- a/matlab/utilities/dseries/from.m +++ b/matlab/utilities/dseries/from.m @@ -153,20 +153,32 @@ end % Check that the recursion is assigning something to a variable equal_id = strfind(EXPRESSION,'='); if isempty(equal_id) - error('The expression following the DO keyword must be an assignment (missing equal symbol)!') + error('Wrong syntax! The expression following the DO keyword must be an assignment (missing equal symbol).') end if isequal(length(equal_id),1) + % Get the name of the assigned variable (with time index) assignedvariablename = regexpi(EXPRESSION(1:equal_id-1), '\w*\(t\)|\w*\(t\-\d\)|\w*\(t\+\d\)','match'); if isempty(assignedvariablename) - error('The expression following the DO keyword must be an assignment (missing variable before the equal symbol)!') + error('Wrong syntax! The expression following the DO keyword must be an assignment (missing variable before the equal symbol).') end if length(assignedvariablename)>1 error('No more than one variable can be assigned!') end - assignedvariablename = assignedvariablename{1}(1:regexpi(assignedvariablename{1},'\(t\)|\(t\-\d\)|\(t\+\d\)')-1); - eval(sprintf('wrongtype = ~isdseries(%s);',assignedvariablename)) - if wrongtype - error('The assigned variable must be a dseries object!') + % Check that the dynamic model for the endogenous variable is not forward looking. + 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