How to fit experimental data on only one ordinary differential equations (out of multiple equations) with multiple unknown parametrs
10 views (last 30 days)
Show older comments
Learner
on 3 Jun 2014
Commented: Johan Sebastian Diaz Tovar
on 21 Nov 2019
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.
Accepted Answer
Star Strider
on 4 Jun 2014
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 Comments
StarSign1997
on 11 Apr 2019
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
on 21 Nov 2019
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.
More Answers (1)
Alex Sha
on 25 Sep 2019
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 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!