Bad Exponential Fit of Data: How to solve a problem with bad parameter estimation

Hello to all.
I need to fit data which should be well fitted by one or two exponential model. I tried to use fit function and non-linear fit.
I am interested only in a decay part after the peaks:
First I tried fit function:
[fitresult1, gof1] = fit(time', y_peak_raw_decay', 'exp1');
[fitresult2, gof2] = fit(time', y_peak_raw_decay', 'exp2');
Here is no explicit error notifiation and looks like 2-exp fit works better.
General model Exp2:
fitresult2(x) = a*exp(b*x) + c*exp(d*x)
Coefficients (with 95% confidence bounds):
a = 2.816e+04 (2.27e+04, 3.362e+04)
b = -0.07659 (-0.09724, -0.05593)
c = 2.428e+04 (1.834e+04, 3.023e+04)
d = -0.007086 (-0.01101, -0.003164)
I suppose that my data has an offset, but fit with exp2 does not take into account and return offset constant. So I tried fitnlm function:
X = time;
Y = y_peak_raw_decay;
tbl = table(X', Y');
modelfun = @(b,x) b(1) * exp(-b(2)*x(:, 1)) + b(3) * exp(-b(4)*x(:, 1))+ b(5);
beta0 = zeros(1,5);
mdl_peak = fitnlm(tbl, modelfun, beta0);
b1 = 8038.37302712328
b2 = 0.394548525519020
b3 = 33291.0317256818
b4 = 0.0433576771723344
b5 = 13612.4854074245
And here I have a warning:
"Warning: Rank deficient, rank = 3, tol = 1.044552e-13.
Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use caution in making
predictions. "
I read here that it means that model really does not describe data well. But my signal is quite standard and it normally can be modeled with exp function. So I suggest I do mistake, but have no idea how to fix it.
I tried to rescale data, because the difference between X and Y is 3-order, that can cause a problem for fitting. It didn't help and I still have the same notification.
Could you please help me to understand where is a problem can lie.

 Risposta accettata

hello
a very simple approach can give you the right answer :
load('Qdata.mat')
% model : y = b*exp(m*x);
P = polyfit(X, log(Yrescaled), 1);
m = P(1);
b = exp(P(2));
t2 = linspace(min(X),max(X),100);
c2 = b*exp(t2*m);
plot(X, Yrescaled, '*r', t2, c2, '-b');
TE = sprintf(' C = %0.6f * e^{%0.6f * t}',b, m);
text(t2(4)+1, c2(4), TE);

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by