Errors when using lsqnonlin in new Matlab version

15 ビュー (過去 30 日間)
Seppe
Seppe 2015 年 3 月 5 日
コメント済み: Matt J 2015 年 3 月 5 日
Hello,
A while ago someone gave me some code to solve my statistics problems (including nonlinear data-fitting). I recently upgraded from Matlab R2010b to R2014b, and now I get error messages like the one below. Does anyone know if something important changed to 'lsqnonlin'? I noticed the errors occur when to most irregular datadistributions are fitted.
Thanks in advance, Seppe
Error using levenbergMarquardt (line 16)
Objective function is returning undefined values at initial point. lsqnonlin
cannot continue.
Error in lsqncommon (line 156)
[xC,FVAL,JACOB,EXITFLAG,OUTPUT,msgData] = ...
Error in lsqnonlin (line 237)
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in SKNrandgen (line 95)
distr_param=lsqnonlin(@SKNfit,distr_param,[],[],OPTIONS,CurrentBootData,n_obs);

採用された回答

Matt J
Matt J 2015 年 3 月 5 日
編集済み: Matt J 2015 年 3 月 5 日
The errors you've posted are not originating from lsqnonlin. They are originating from the objective function, SKNfit. It is returning NaNs, or Infs, or something not legal at the initial point. You should forget about lsqnonlin for now and just focus on SKNfit. Check what it is returning at the initial point.
  2 件のコメント
Seppe
Seppe 2015 年 3 月 5 日
Indeed! There was an ill-working interpolation in SKNfit. I changed the line below into the one beneath it and the problem was solved. Strange that this problem did not occur in the old Matlab version though.
Thank you very much!
SKNdata=interp1(cumm_modelfreq(array_temp),class_model(array_temp),cumm_fitdata);
SKNdata=interp1(cumm_modelfreq(array_temp),class_model(array_temp),cumm_fitdata,'linear','extrap');
Matt J
Matt J 2015 年 3 月 5 日
It's probably because some of your cumm_fitdata is close to the boundary of your interpolated region cumm_modelfreq(array_temp). Small changes in the order of floating point operations between MATLAB versions can put it outside the interpolated region where it will get assigned NaN by default.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by