Fitting a 4 variable nonlinear equation using lsqcurvefit

I tried to fit my data to a multi-exponential function using "lsqcurvefit" and to find out the coefficients. It gives an unexpected error, "The Levenberg-Marquardt algorithm does not handle bound constraints and the trust-region-reflective algorithm requires at least as many equations as variables; aborting."
As for matlab examples given for simple exponential function, it works fine. Any idea to figuring this out?
xdata=[50 400 800];
ydata=[350 200 90];
ff=@(x,b) x(1)*(x(2)*exp(-(x(3)+x(4))*b)+(1-x(2))*exp(-x(4)*b));
x0=[1,0.2,0.01,0.001]; %guess values
lb=[0, 0, 0.005, 0];
ub=[1500, 1, 0.1, 0.005];
options = optimset('Algorithm','levenberg-marquardt','MaxFunEvals',1e9,'MaxIter',1e9,'TolFun', 1e-8, 'TolX', 1e-8);
X=lsqcurvefit(ff,x0,xdata,ydata,lb,ub,options);
disp(X)

 採用された回答

Star Strider
Star Strider 2015 年 9 月 30 日

2 投票

You are estimating four parameters with three data pairs. You cannot uniquely estimate more parameters than you have data. (Consider estimating a line — defined by two parameters — when you have only one point. An infinite number of lines could be drawn through that point.)

4 件のコメント

JayD
JayD 2015 年 10 月 1 日
That makes sense now. Thank you so much. Since I cannot add more data to this specific problem, I will have to come up with another technique to use this model function. Any suggestions on that?
Star Strider
Star Strider 2015 年 10 月 1 日
My pleasure.
A simple sum-of-exponentials is rarely a good model anyway. It is best that you derive a mathematical model your system and develop an objective function to fit that model to your data, so that the parameters have physical meaning.
In the interim, a single exponential would likely work with the data you have. I’d use something like this:
f = @(x,b) x(1) + x(2).*exp(x(3).*b);
(This is untested code.)
JayD
JayD 2015 年 10 月 1 日
Thank you so much. It works for me. Appreciate your comments.
Star Strider
Star Strider 2015 年 10 月 1 日
My pleasure.
The most sincere expression of appreciation here on MATLAB Answers is to Accept the Answer that most closely solves your problem.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2015 年 9 月 30 日

コメント済み:

2015 年 10 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by