What does this lsqnonlin error mean?

5 ビュー (過去 30 日間)
Amir Patel
Amir Patel 2013 年 9 月 13 日
Hi
I'm attempting a nonlinear parameter fit using lsqnonlin and a Simulink model. I'm following a similarly method to: http://www.mathworks.com/help/optim/ug/lsqnonlin-with-a-simulink-model.html
After the function starts, I get this weird error below. What does it mean?
First-Order Norm of
if true
% Iteration Func-count Residual optimality Lambda step
0 3 231.377 51.4 0.01
1 6 179.496 51.1 0.001 6.82145
Subscripted assignment dimension mismatch.
Error in C:\MATLAB\R2012a Student\toolbox\shared\optimlib\finitedifferences.p>finitedifferences (line 159)
Error in levenbergMarquardt (line 235)
[JAC,~,~,numEvals,evalOK] = finitedifferences(XOUT,funfcn{3},[],[],[],costFun, ...
Error in lsqncommon (line 181)
[xC,FVAL,JACOB,EXITFLAG,OUTPUT,msgData] = ...
Error in lsqnonlin (line 235)
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in runSpringDamplsq (line 34)
param = lsqnonlin(@springDamplsq, param0, [], [], options);
end

採用された回答

Steve Grikschat
Steve Grikschat 2013 年 9 月 13 日
This error is occurring because your function is returning arrays of varying sizes. In this case, it is being caught during finite-difference estimation of the function's Jacobian.
Check your function that you pass to lsqnonlin and make sure that it returns an array with a consistent number of elements.
  1 件のコメント
Amir Patel
Amir Patel 2013 年 9 月 13 日
100% correct. I was stopping the simulation when end conditions were reached. This resulted in varying size arrays.
Thank you for the help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLeast Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by