curve fitting using lsqcurvefit on kinetic data for parameter estimation
이전 댓글 표시
Hello,
I am fitting some experimental data (protein digestion kinetics) to the following model y = ymax+(ymax-y0)*exp(-k*t) using lsqcurvefit, were t is time (independent variable), y is concentration (dependent variable), and k, ymax and y0 are coefficient representing, respectively, the rate of the reaction, the maximum final concentration and the initial concentration.
The fitting seems to work well but the issue I cannot understand is why I get values of ymax higher than y0 when it should be the opposite.
Below you can find the code I'm using, do you have any idea/suggestion on where the issue could be?
Thanks a lot in advance for the hepl!!
xdata=[0; 30; 60; 90; 120; 180; 240];
ydata=[1.607; 2.346; 2.621; 2.967; 3.238; 3.479; 3.566];
coef = ["ymax","y0","k","R2","R2adj","RMSE"];
fun = @(x,xdata) x(1)+(x(1)-x(2))*exp(-x(3)*xdata)
x0 = [1,1,0.01];
lb = [0,0,0];
ub = [10,10,0.5];
[x,resnorm,residual,exitflag,output] = lsqcurvefit(fun,x0,xdata,ydata,lb,ub);
figure(1);
plot(xdata,ydata,'o',xdata,fun(x,xdata),'-');
SSresid = sum(residual.^2);
SStotal = (numel(ydata)-1) * var(ydata);
R = 1 - SSresid/SStotal;
Radj = 1 - (SSresid/SStotal) * ((numel(ydata)-1)/(numel(ydata)-1-1));
RMSE = rmse(fun(x,xdata),ydata);
r = [x R Radj RMSE];
coef = [coef;r];
figure(2);
scatter(xdata,residual);
coef
채택된 답변
추가 답변 (1개)
Umang Pandey
2024년 11월 5일
1 개 추천
Hi Federico,
Looking at your xdata and ydata, your ydata is increasing with increase in xdata, but the delta for each consecutive increase decreases, implying it is fitting "y = a - bexp(-kx)" where a,b,k are > 0. Since you are expecting "ymax > y0", your ydata should have been decreasing with increase in xdata, with the delta also decreasing for each consecutive decrease.
I have attached the following curves for your reference:
Case 1 : y = 4 - 3*exp(-2x) ; Assumptions : ymax = 4, y0 = 7, k = 2
Case 2 : y = 4 + 3*exp(-2x) ; Assumptions : ymax = 4, y0 = 1, k = 2

As you can see from the curve, your data/curve you obtained fits the first case.
Hope this helps!
Best,
Umang
카테고리
도움말 센터 및 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!




