Finding parameters of ODEs using lsqcurvefit
Afficher commentaires plus anciens
I have written the following function, and then trying to call this function using lsqcurvefit to fit the experimental data to my ordinary differential equations. it seems that I have a problem in calling lsqcurvefit. Please take a look at my codes and tell me what my problem is. Thank you.
here is my function:
function S = Kinetics(B, t)
% KINETICS codes the system of differential equations describing
% COD and FCL behavior in the washing system:
% dO/dt = k0;
% dC/dt = k1*O*C;
% with:
% Variables: x(1) = O, x(2) = C
% Parameters: k0 = B(1), k1 = B(2)
x0 = [305,25];
[T,Sv] = ode45(@DifEq, t,x0);
function dS = DifEq(t, x)
xdot = zeros(2,1);
xdot(1) = B(1);
xdot(2) = -B(2) .* x(2) .* x(1);
dS = xdot;
end
S = Sv;
end
And this is how I have used "lsqcurvefit ":
Time = [0 2 4 6 8 10 12];
COD=[307.18 394.39 441.93 516.62 565.13 636.74 653.68];
Fcl = [21.06666667 15.4 9.633333333 4.666666667 0.753333333 0.403333333 0.206666667];
B0 = [COD(1),Fcl(1)];
[B,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@Kinetics, B0, Time(:), COD(:), Fcl(:));
parameters = B
3 commentaires
Jan
le 3 Juil 2018
it seems that I have a problem
Then please explain the problem you observe.
Ryan Abnavi
le 3 Juil 2018
Alex Sha
le 25 Août 2021
Please refer to the results below, stable and unique:
Root of Mean Square Error (RMSE): 11.0726433185545
Sum of Squared Residual: 1716.44802083901
Correlation Coef. (R): 0.992799844135045
R-Square: 0.98565153051457
Parameter Best Estimate
-------------------- -------------
k0 28.482650276005
k1 -0.000561833672907692

Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!