How are initial values chosen for either lsqcurvefit or nlinfit functions?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I want to fit my experimental data to a theoretical model which contains an exponential. I've attached a copy of the code I'm using. I've tried various x0 matrix values, but the same error message keeps popping up:
Caused by: Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
댓글 수: 1
Walter Roberson
2018년 9월 19일
The code did not get attached.
답변 (3개)
Torsten
2018년 9월 19일
0 개 추천
There must be some mathematical operation within your objective function that gives Inf, NaN or something similar (e.g. division by zero, log or sqrt of a negative number, exponentiation of a negative number ...).
Best wishes
Torsten.
댓글 수: 0
Ken Mathai
2018년 9월 19일
편집: Walter Roberson
2018년 9월 19일
댓글 수: 3
Torsten
2018년 9월 19일
Here the error is that
fun=@(x,xdata)(x(1)*xdata+x(2)*xdata.*xdata);
must be used instead of
fun=@(x,xdata)(x(1)*xdata+x(2)*xdata*xdata);
Furthermore, y=p1*x+p2*x^2 is a linear parameter estimation problem. No need to use "lsqcurvefit" here.
What I mean is: Look for expressions in your function that evaluate to Inf or NaN (e.g. p(1)/xdata where some of the xdata are zero or log(x(1)) (the parameter vector can become negative), or ...)
Best wishes
Torsten.
Ken Mathai
2018년 9월 19일
Torsten
2018년 9월 19일
Linear means: The equation is linear in the parameters.
It is irrelevant how "xdata" enters the equation.
Thus in your case x(1) and x(2) are simply given by
x = [xdata xdata.^2]\ydata
where xdata and ydata are your respective column vectors.
Best wishes
Torsten.
Ken Mathai
2018년 9월 19일
0 개 추천
댓글 수: 1
Torsten
2018년 9월 20일
It should suffice to have the Optimization Toolbox (lsqcurvefit, fmincon,...)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!