lsqnonlin triggering error for incompatible array sizes
古いコメントを表示
I am currently working on a system identification task, where I want to determine parameters used in a simulink model. The model output is compared with measured real-world values within a cost-function. Now I want to use lsqnonlin to solve for optimal model parameters.
This process workes in many cases, but depending on the initial values I sometimes get the following error:
Norm of First-order
Iteration Func-count f(x) step optimality
0 9 5.95176 6.49e+04
1 18 1.77504 0.0600514 1.63e+04
Arrays have incompatible sizes for this operation.
Error in twoStepFinDiffFormulas
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 lsqncommon (line 179)
snls(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,...
Error in model_identification (line 77)
[X,RESNORM,RESIDUAL,EXITFLAG]=lsqnonlin(@minFunction,...
As one can see, the optimization already executed several iterations before the error happens and sometimes, depending on the initial values, the minimum is found even without an error. Looking at the function-call-stack I am tempted to believe, that in some cases the lsqnonlin algorithm calls some internal functions with invalid parameters. Is there something obvious I am missing or could there be a problem within the lsqnonlin algorithm?
採用された回答
その他の回答 (1 件)
Matt J
2021 年 11 月 3 日
0 投票
I don't think you are missing something obvious, but it is doubtful that the problem is in the lsqnonlin algorithm. Use dbstop to trap the occurrence of the error and test your objective function with whatever set of parameters triggers the error.
カテゴリ
ヘルプ センター および File Exchange で Manual Performance Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!