Finding parameters of ODEs using lsqcurvefit
이전 댓글 표시
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
Jan
2018년 7월 3일
it seems that I have a problem
Then please explain the problem you observe.
Ryan Abnavi
2018년 7월 3일
Alex Sha
2021년 8월 25일
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

채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!