How to fit differential equations to a curve
11 次查看(过去 30 天)
显示 更早的评论
Hi,
I have an equation dc/dt = 6k1 - k1t - k2t^2
I need to find the values of k1 and k2 from the plot data:
t = [5 10 20 30 45 60 90 120];
c = [4.83 3.87 2.54 2.08 1.82 1.8 1.76 1.74];
How do I go about this?
Thanks for your help.
0 个评论
采纳的回答
Star Strider
2019-8-17
I would normally suggest that you see Monod kinetics and curve fitting and others. However this is actually a linear problem, so first use the Symbolic Math Toolbox to integrate your differential equation, then since this is a linear problem, use a linear approach to estimate the parameters.
syms c(t) k1 k2 t c0
Eqn = diff(c) == 6*k1 - k1*t - k2*t^2;
C = dsolve(Eqn, c(0) == c0)
t = [5 10 20 30 45 60 90 120];
c = [4.83 3.87 2.54 2.08 1.82 1.8 1.76 1.74];
B = [ones(size(t(:))), 6*t(:)-t(:).^2/2, -t(:).^3/3] \ c(:)
cf = [ones(size(t(:))), 6*t(:)-t(:).^2/2, -t(:).^3/3] * B;
figure
plot(t, c, 'p')
hold on
plot(t, cf, '-r')
hold off
grid
Your differential equation is trivial to integrate, although as long as we have access to the Symbolic Math Toolbox, we might as well use it to do the integration, careating ‘Ct’. The linear parameter estimation ‘B’ calculation essentially copies ‘Ct’.
2 个评论
Vivek E K
2021-6-21
What is the meaning of these steps?
B = [ones(size(t(:))), 6*t(:)-t(:).^2/2, -t(:).^3/3] \ c(:)
cf = [ones(size(t(:))), 6*t(:)-t(:).^2/2, -t(:).^3/3] * B;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!