Azzera filtri
Azzera filtri

How to fit differential equations to a curve

26 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 17 Ago 2019
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 Commenti
Vivek E K
Vivek E K il 21 Giu 2021
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;

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by