Allow log(-X) or diff(-X) on the LHS.
parent
5d8babb15c
commit
fd2cb24911
|
@ -213,17 +213,23 @@ function [lhs, rhs] = getequation(str)
|
||||||
terms = strsplit(str, {'=',';'});
|
terms = strsplit(str, {'=',';'});
|
||||||
terms(cellfun(@(x) all(isempty(x)), terms)) = [];
|
terms(cellfun(@(x) all(isempty(x)), terms)) = [];
|
||||||
terms(1) = {strrep(terms{1}, ' ', '')};
|
terms(1) = {strrep(terms{1}, ' ', '')};
|
||||||
lhs = regexp(terms{1}, '^(diff\(\w*\)|log\(\w*\)|diff\(diff\(\w*\)\)|diff\(log\(\w*\)\)|diff\(diff\(log\(\w*\)\)\)|\w*)', 'match');
|
lhs = regexp(terms{1}, '^(diff\((log|diff)\([\-\+\*\/\w]*\)\)|(log|diff)\([\-\+\*\/\w]*\)|\w*)', 'match');
|
||||||
if ~isempty(lhs)
|
if ~isempty(lhs)
|
||||||
lhs = lhs{1};
|
lhs = lhs{1};
|
||||||
|
if isequal(lhs, 'log')
|
||||||
|
error('Malformed equation: log of log or diff are not allowed.')
|
||||||
|
end
|
||||||
rhs = terms{2};
|
rhs = terms{2};
|
||||||
else
|
else
|
||||||
error('Malformed equation.')
|
error('Malformed equation.')
|
||||||
end
|
end
|
||||||
|
|
||||||
function v = getendovar(lhs)
|
function v = getendovar(lhs)
|
||||||
v = strsplit(lhs, {'diff','log','(',')'});
|
v = strsplit(lhs, {'diff','log','(',')', '+', '-', '*', '/'});
|
||||||
v(cellfun(@(x) all(isempty(x)), v)) = [];
|
v(cellfun(@(x) all(isempty(x)), v)) = [];
|
||||||
|
if length(v)>1
|
||||||
|
error('Malformed equation: no more than one endogenous variable can be used on the LHS.')
|
||||||
|
end
|
||||||
|
|
||||||
function [v, t] = getvarandtag(str)
|
function [v, t] = getvarandtag(str)
|
||||||
tmp = regexp(str, '(?<name>\w+)\s*(?<tag>\(.*\))', 'names');
|
tmp = regexp(str, '(?<name>\w+)\s*(?<tag>\(.*\))', 'names');
|
||||||
|
|
Loading…
Reference in New Issue