PAC NLS estimation: Octave compatibility fix

In regular expressions, the end-of-word operator (\>) does not behave the same
under Octave and under MATLAB. See:
https://savannah.gnu.org/bugs/index.php?59992

In this case, we can simply drop the \> operator, since there is no risk of
matching a partial variable name (since there is already “(-1)” at the end of
the pattern).

By the way, remove a useless parenthesis grouping in the regexp.
time-shift
Sébastien Villemot 2021-02-02 16:59:58 +01:00
parent 7bbe67748b
commit 8e9085eea4
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 2 additions and 2 deletions

View File

@ -104,9 +104,9 @@ for i=1:length(objNames)
end
j = regexp(rhs, ['\<', objNames{i}, '\>']);
if islaggedvariables
jlag = regexp(rhs, ['\<(', objNames{i}, '\(-1\))\>']);
jlag = regexp(rhs, ['\<', objNames{i}, '\(-1\)']);
if ~isempty(jlag)
rhs = regexprep(rhs, ['\<(' objNames{i} '\(-1\))\>'], sprintf('data(1:end-1,%u)', k));
rhs = regexprep(rhs, ['\<' objNames{i} '\(-1\)'], sprintf('data(1:end-1,%u)', k));
end
if ~isempty(setdiff(j, jlag))
rhs = regexprep(rhs, ['\<' objNames{i} '\>'], sprintf('data(2:end,%u)', k));