Is this a bug in lsqcurvefit?

조회 수: 3 (최근 30일)
Catalytic
Catalytic 2019년 3월 29일
댓글: Matt J 2019년 4월 4일
When I run this simple test of lsqcurvefit (this is R2018a), I get errors.
opts=optimoptions(@lsqcurvefit,'SpecifyObjectiveGradient',true,...
'JacobianMultiplyFcn',@Jfun);
p=lsqcurvefit(@modelfun,2,10,11,[],[],opts)
function [y,Jinfo]=modelfun(p,xdata)
y=xdata-p;
Jinfo=0;
end
function out=Jfun(Jinfo,Y,flag)
out=0;
end
The errors are
Too many input arguments.
Error in lsqcurvefit/jacobmult (line 291)
W = feval(mtxmpy_xdata,Jinfo,Y,flag,XDATA,varargin{:});
Error in snls (line 199)
g = feval(mtxmpy,A,fvec(:,1),-1,varargin{:});
Error in lsqncommon (line 167)
snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller,
...
Error in lsqcurvefit (line 271)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,allDefaultOpts,caller,...
Error in test1 (line 6)
p=lsqcurvefit(@modelfun,2,10,11,[],[],opts)
Looking at line 291 in lsqcurvefit shows that it is in fact trying to pass xdata as a 4th argument to the JacobMult function
function W = jacobmult(Jinfo,Y,flag,varargin)
W = feval(mtxmpy_xdata,Jinfo,Y,flag,XDATA,varargin{:});
end
I can see why it would make sense to pass xdata to the user-provided JacobMult function, in addition to Jinfo,Y, and flag, but nowhere in the documentation does it say to format the JacobMult function this way. Is this a coding bug or a documentation bug?
  댓글 수: 1
Matt J
Matt J 2019년 4월 4일
Another question, sort of on the same subject. When the JacobianMutiplyFcn is used, what does the solver return for the jacobian output in the following?
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(___)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Physics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by