I want to find rate constant from function fminsearch.

3 visualizaciones (últimos 30 días)
Nattanit Benjangvisanu
Nattanit Benjangvisanu el 22 de En. de 2022
Comentada: Nattanit Benjangvisanu el 22 de En. de 2022
clear all
t=15,30,60,120,240; %min
dCHMF/dt= -k1CHMF;
dCHMFCA/dt= -k2CHMFCA+k1CHMF;
dCFFCA/dt= -k3CFFCA+k2CHMFCA;
dCFDCA/dt= k4CFDCA;
CHMF initial =0.1 %mol/L
Conc.(mol/L)
t HMF HMFCA FFCA FDCA
15 0.04401 0.00127 0.00120 0.00000
30 0.04924 0.00097 0.00269 0.00000
60 0.03023 0.00575 0.00540 0.00005
120 0.03132 0.00877 0.01296 0.00007
240 0.04457 0.00053 0.00278 0.00000
objective function as follow from this equation.
I want to find k1,k2,k3 and k4 from fuction fminsearch.
  2 comentarios
John D'Errico
John D'Errico el 22 de En. de 2022
Editada: John D'Errico el 22 de En. de 2022
5 data points, and you want to estimate 4 unknown parameters?
I would note that you spedify only ONE of the initial values, and there must be 4 initial values specified to solve any such problem.
Are those data points known EXACTLY, with no error at all? Surely not, since one of the species has concentration 0 at 4 of the 5 points. I wish you good luck.
Nattanit Benjangvisanu
Nattanit Benjangvisanu el 22 de En. de 2022
I don't know how to wrote a code. I try to find k1,k2,k3,k4 another way but I can't. Matlab is hard for me lol.

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 22 de En. de 2022
Here is a start. First, fminsearch will probably be a poor solver to use here. At least, make sure you have good starting values.
ANd since you have not specified initial values for the ODE, I'll assume they are all zero except for the one you DID specify.
syms CHMF(t) CHMFCA(t) CFFCA(t) CFDCA(t) k1 k2 k3 k4
EQ = [diff(CHMF) == -k1*CHMF;...
diff(CHMFCA) == -k2*CHMFCA+k1*CHMF;...
diff(CFFCA) == -k3*CFFCA+k2*CHMFCA;...
diff(CFDCA) == k4*CFDCA];
IC = [CHMF(0) == 0.1, CHMFCA(0) == 0, CFFCA(0) == 0, CFDCA(0) == 0];
sol = dsolve(EQ,IC)
sol = struct with fields:
CHMFCA: (k1*exp(-k2*t))/(10*(k1 - k2)) - (k1*exp(-k1*t))/(10*(k1 - k2)) CHMF: exp(-k1*t)/10 CFFCA: (k1*k2*exp(-k1*t))/(10*(k1 - k2)*(k1 - k3)) - (k1*k2*exp(-k2*t))/(10*(k1 - k2)*(k2 - k3)) + (k1*k2*exp(-k3*t))/(10*(k1 - k3)*(k2 - k3)) CFDCA: 0
You should see that the last component is identically zero, since it started out at zero concentration. That leaves you with 3 unknowns, and 5 data points for them on each curve. But the nice thing is, you now need not use an ode solver, since the analytical solution was easy to arrive at.
Just use an nonlinear least squares solver you want to use.
  3 comentarios
Torsten
Torsten el 22 de En. de 2022
Add the lines
sol.CHMF
sol.CHMFCA
sol.CFFCA
sol.CFDCA
after
sol = dsolve(EQ,IC)
Nattanit Benjangvisanu
Nattanit Benjangvisanu el 22 de En. de 2022
How to solve k1,k2,k3,k4 are number?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by