Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How are initial values chosen for either lsqcurvefit or nlinfit functions?

1 回表示 (過去 30 日間)
Ken Mathai
Ken Mathai 2018 年 9 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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
Walter Roberson 2018 年 9 月 19 日
The code did not get attached.

回答 (3 件)

Torsten
Torsten 2018 年 9 月 19 日
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.

Ken Mathai
Ken Mathai 2018 年 9 月 19 日
編集済み: Walter Roberson 2018 年 9 月 19 日
So if I have the following:
xdata=cranialStrain
ydata=cranialStress
fun=@(x,xdata)(x(1)*xdata+x(2)*xdata*xdata);
x0 = [0.1 0.1 0];
x = lsqcurvefit(fun,x0,xdata,ydata)
I should be careful that my data does not include negative numbers for ydata, as that would cause issues for the model equation?
  3 件のコメント
Ken Mathai
Ken Mathai 2018 年 9 月 19 日
hmm. I'm not sure why you say this is a linear parameter estimation problem. Isn't the fact that the xdata is being squared make the model a quadratic?
Also, I made the proposed change to xdata in the multiplication and I reformatted the axes to not include negative numbers. This allowed me to run the code without error!
Torsten
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
Ken Mathai 2018 年 9 月 19 日
Ah, ok. But what other way is there to fit the data to my model equation? I also do not have the cftool box.
  1 件のコメント
Torsten
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!

Translated by