How to fit differential equations to a curve

19 ビュー (過去 30 日間)
Titas Deb
Titas Deb 2019 年 8 月 17 日
コメント済み: Star Strider 2021 年 6 月 21 日
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;
Star Strider
Star Strider 2021 年 6 月 21 日
Linear fit to the data.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by