How to fit differential equations to a curve

26 次查看(过去 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.

采纳的回答

Star Strider
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
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 CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by