How to fit differential equations to a curve

조회 수: 26 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by