Clear Filters
Clear Filters

Why 'Arrays have incompatible sizes for this operation' happens in lsqnonlin fitting

2 views (last 30 days)
error messages:
Arrays have incompatible sizes for this operation.
Error in finitedifferences
Error in computeFinDiffGradAndJac
Error in sfdnls (line 54)
computeFinDiffGradAndJac(x,funfcn,confcn,valx, ...
Error in snls (line 343)
[newA, findiffevals] = sfdnls(xcurr,newfvec,Jstr,group,alpha, ...
Error in snlsFixedVar (line 128)
[xcurr,fvec,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData] = snls(funfcn,xstart(idxFree),l(idxFree),u(idxFree),verb,options, ...
Error in lsqncommon (line 175)
snlsFixedVar(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller, ...
Error in lsqnonlin (line 260)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,...
Hello, thanks for your time.
I am running a lsqnonlin non-linear fitting. There are about seven input parameters and a series of data to fit. Initially the fit goes good, but after I changed parts of the functions, these errors are reported when it goes about tens of iterations. I have checked the code and there are no incompatible arrays or any NaN or [] value occur. Could anyone help get out why this happens?
The only idea I got is that one parameter involves in a logical comparison. But it also show no problem when I check the detail value.
  2 Comments
Walter Roberson
Walter Roberson on 2 Dec 2021
one parameter involves in a logical comparison
lsqnonlin() is not valid on discontinuous systems. I am not certain at the moment, but I believe it also requires continuous first derivatives. Depending on the options, it may also require continuous second derivatives -- and by "may" I mean that the default options require continuous second derivatives.

Sign in to comment.

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!