From 8e9085eea4bd52496c86d2f52119ab9420c9ce1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 2 Feb 2021 16:59:58 +0100 Subject: [PATCH] PAC NLS estimation: Octave compatibility fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- matlab/+pac/+estimate/nls.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/+pac/+estimate/nls.m b/matlab/+pac/+estimate/nls.m index 77f2180ab..afd9f1366 100644 --- a/matlab/+pac/+estimate/nls.m +++ b/matlab/+pac/+estimate/nls.m @@ -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));