diff --git a/matlab/olseqs.m b/matlab/olseqs.m index dc780bac5..283332fad 100644 --- a/matlab/olseqs.m +++ b/matlab/olseqs.m @@ -39,13 +39,17 @@ end jsonmodel = loadjson(jsonfile); jsonmodel = jsonmodel.model; -[lhs, rhs, ~] = getEquationsByTags(jsonmodel, varargin{:}); +[lhs, rhs, lineno] = getEquationsByTags(jsonmodel, varargin{:}); Y = ds{lhs}.data; rhs_ = strsplit(rhs, {'+','-','*','/','^','log(','exp(','(',')'}); rhs_(cellfun(@(x) all(isstrprop(x, 'digit')), rhs_)) = []; vnames = setdiff(rhs_, cellstr(M_.param_names)); +regexprnoleads = cell2mat(strcat('(', vnames, {'\(\d+\))|'})); +if ~isempty(regexp(rhs, regexprnoleads(1:end-1), 'match')) + error(['olseqs: you cannot have leads in equation on line ' lineno ': ' lhs ' = ' rhs]); +end regexpr = cell2mat(strcat('(', vnames, {'\(-\d+\))|'})); vwlags = regexp(rhs, regexpr(1:end-1), 'match'); X = cell2mat(cellfun(@eval, strcat('ds.', vwlags, '.data'), 'UniformOutput', false)); diff --git a/matlab/plot_contributions.m b/matlab/plot_contributions.m index 8a673fc0a..5cf42f13e 100644 --- a/matlab/plot_contributions.m +++ b/matlab/plot_contributions.m @@ -54,6 +54,11 @@ pnames = cellstr(M_.param_names); vnames = setdiff(rhs_, pnames); pnames = setdiff(rhs_, vnames); +regexprnoleads = cell2mat(strcat('(', vnames, {'\(\d+\))|'})); +if ~isempty(regexp(rhs, regexprnoleads(1:end-1), 'match')) + error(['plot_contributions: you cannot have leads in equation on line ' lineno ': ' lhs ' = ' rhs]); +end + % Get values for the parameters idp = strmatch(pnames{1}, M_.param_names, 'exact'); str = sprintf('%s = M_.params(%d);', pnames{1}, idp);