Curve fitting to data using fit
显示 更早的评论
I have data x sampled at times t. I would like to fit my function to this data. Below is a code.
clear; close all
x=[100; 85.4019292604501; 77.9310344827586; 79.3365583966828; 70.3524533;
13.213644524237; 24.5654917953199; 12.6526340272125;
9.71822886716503; 9.99113213124446; 10.525];
t=[0; 24; 24; 24; 24; 48; 48; 48; 72; 72; 72;];
mdl=fittype('A*exp((-C.*(1-exp(-lambda.*t))/lambda)-(D*(exp(-lambda.*t)-1+lambda.*t)/lambda^2))','indep','t');
fittedmdl = fit(t,x,mdl,'start',[0.1 0.1 0.1 0.1])
plot(fittedmdl,'k.')
hold on
plot(t,x,'.m', MarkerSize=20)
And I obtain the following figure:

I am not impressed with the fitting. Can someone please check where I could be going wrong. Thanks in anticipation.
9 个评论
Ghazwan
2022-10-11
Is there a fit quality you are looking for?
Editor
2022-10-11
That is not a lot a data points to fit a rather complex equation to. Can you confirm that the equation as coded is correct?
syms A C D lambda t
A*exp((-C.*(1-exp(-lambda.*t))/lambda)-(D*(exp(-lambda.*t)-1+lambda.*t)/lambda^2))
Ghazwan
2022-10-11
ok. It looks like this is higher order fitting model.
Matt J
2022-10-11
Your starting guess [0.1 0.1 0.1 0.1] looks very arbitrary. Surely you do not expect lambda to have a similar value to the other parameters like A.
Editor
2022-10-11
John D'Errico
2022-10-11
You CANNOT fit a higher order model to this data. If you do, expect garbage. Why? You have only 4 data points, even though some of them are replicates. So no more than 4 parameters can be estimated. At least if you want them to make any sense. And even at that, expect poor results.
As far as getting poor results, you need to provide good starting values for exponential models. Provide crappy or random starting values, then expect crappy/random results. I don't have time right now to look seriously at your data to decide if the model can fit that data, or what are good starting values. I'll look back in later today though.
Editor
2022-10-11
Cris LaPierre
2022-10-11
Just responding about the missing negative sign. The negative sign before C has been applied to the contents inside parentheses. So it is there.
-C(1-exp(
t)) is the same as C(exp(
t)-1)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




