필터 지우기
필터 지우기

nonlinear least squares function

조회 수: 3 (최근 30일)
Khalid
Khalid 2015년 4월 24일
댓글: Khalid 2015년 4월 30일
Hi dears
I would like to ask for more information about nonlinear least squares, i was using it as follow
mas=[s y x z] [x,resnorm,residual,exitflag,output,lambda,j]=lsqnonlin('myfun',mas); s=x(1); y=x(2); x=x(3); z=x(4);
my function was as follow: function [f]=myfun(x) load data.txt i1=data(1:1250,2); v=data(1:1250,1); g=(i1./v); f=((g.*(v.*i1))./((x(1)*x(2)).*g.^(x(3)+x(4))))-(g./(x(1).*g.^x(4))); end
It was giving me this message objective function is returning undefined values at initial point. lsqnonlin cannot continue.
Thanks for your attention and time

채택된 답변

Brendan Hamm
Brendan Hamm 2015년 4월 24일
편집: Brendan Hamm 2015년 4월 24일
If you call your objective function with the variable mas are there any NaNs or Infs in it?
any(isnan(myfun(mas))) || any(isinf(myfun(mas)))
If the answer is a logical 1 (as I suspect), then you have a non-feasible starting point. Try readjusting your initial guess. MATLAB does not know how to adjust your input vector in this case. This is likely due to a division by 0 returning an Inf, but could be a 0/0 case returning a NaN.
  댓글 수: 1
Khalid
Khalid 2015년 4월 30일
Thank you very much that was the case but I was looking for a code which can update my new parameters automatically by giving it the initial number.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Trimming and Linearization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by