Fix NLS estimation routine.

Closes #1798
pac-components
Stéphane Adjemian (Ryûk) 2021-09-01 10:35:45 +02:00
parent 7c0af1ce48
commit 380fd84cb3
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
1 changed files with 19 additions and 2 deletions

View File

@ -136,10 +136,27 @@ else
end
end
% Remove residuals from the equation. Note that a plus or minus will
% remain in the equation, but this seems to be without consequence.
% Remove residuals from the equation. Note that a plus or minus will remain in the equation
rhs = regexprep(rhs, rname, '');
% FIXME The JSON output for rhs (with aux variables substitutions) is not always
% the same regarding to the position of the residual. If the residual appears at
% the end of the equation, after the removal of rname the rhs will end with a +
% symbol which will result in a crash later when evaluating the sum of square
% residuals. If the residual appears at the begining of the equation, after the
% removal of rname the rhs will begin with a + symbol which is just awful (but
% will not cause any trouble).
% Remove trailing + (if any, introduced when removing residual)
if isequal(rhs(end), '+')
rhs = rhs(1:end-1);
end
% Remove leading + (if any, introduced when removing residual)
if isequal(rhs(1), '+')
rhs = rhs(2:end);
end
%
% Rewrite and print the equation.
%