How to fit experimental data on only one ordinary differential equations (out of multiple equations) with multiple unknown parametrs
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi,
I am trying to estimate 3 unknown parameters that exist in 3 ordinary differential equations (ODEs) by fitting it to experimental data of only one ODE.
My equations are:
dy1/dt = (c(1)*y1.^2) + (c(2)*(y2)) - (c(3)*y3);
dy2/dt = (c(3)*y3) + (c(4)*y1);
dy3/dt = (c(1)*y1.^2) - (c(5)*y2) + (c(3)*y3);
My experimental 'x-axis data (time axis)' and 'y-axis data' for dy3/dt is as follows:
xdata = [0 1 2 3 4 5 6 7 8 9];
ydata = [3 17 9 4 8 2 1 9 2 4].
Starting guess of unknown parameters: c(1), c(2), c(3) i.e.
c0 = [1, 1, 1]; where c(4) and c(5) are known = 2 and 1.5.
Thanks in advance.
채택된 답변
Star Strider
2014년 6월 4일
The strategy is to put your differential equation and the ODE solver call inside the objective function you want to fit. It integrates the equations with the parameters passed to it, and returns the solved equation as the output of the objective functions. You can specify that c(4) and c(5) are known inside the objective function file, and only fit c(1)...c(3). Specify the initial conditions inside the objective function, or you can also fit them as parameters if you wish. (I’ve done all those.)
With a vector output, you can use nlinfit, lsqcurvefit, or with an extra step, fminsearch to do the fit.
댓글 수: 14
StarSign1997
2019년 4월 11일
I copied and pasted the code here but an error occurs saying function value and YDATA are not equal in size. I am confused.
Johan Sebastian Diaz Tovar
2019년 11월 21일
StarSign1997 when copy the code make sure to take the transpose of Sdata, if you don't do that, you'll get that error. So: Sdata = Sdata'; Doing this you solve that.
regards.
추가 답변 (1개)
Alex Sha
2019년 9월 25일
How about the results below:
Root of Mean Square Error (RMSE): 2.11836006576677
Sum of Squared Residual: 40.3870443141185
Correlation Coef. (R): 0.897567768947133
R-Square: 0.805627899852735
Adjusted R-Square: 0.740837199803646
Determination Coef. (DC): 0.805415739385938
F-Statistic: 4.2201395530756
Parameter Best Estimate
-------------------- -------------
c1 -0.607049737407678
c2 -1.63508159310052
c3 -0.00144177544567964
y1 Initial Value -8.12681195260699
y2 Initial Value -25.9407402385313
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!