How to solve this system of ODEs

1 view (last 30 days)
Sun
Sun on 22 Aug 2019
Answered: John D'Errico on 23 Aug 2019
Hi,
I have a system in the form of something like this (a * dy/dt) + (b * y) = (c * dx/dt) + (d * x). Data is available for variables x, y & t. How to estimate parameters a, b, c & d?
Is there any in-built tool on MATLAB that can take custom equations like these? Please let me know. Thanks!
Best,
Sun

Accepted Answer

John D'Errico
John D'Errico on 23 Aug 2019
You have ONE equation, not a system of ODEs.
(a * dy/dt) + (b * y) = (c * dx/dt) + (d * x)
But suppose you knew the true solution for those coefficients, estimated as [a, b, c, d], as the "optimal" set of coefficients. Can you know then that [2*a, 2*b, 2*c, 2*d] is not just as good of a solution? In fact, pick any constant k, and we can see that the set [k*a, k*b, k*c, k*d] is a solution as good as any other. k can even be zero.
That tells you that your problem is not well posed. You can choose ANY of those 4 coefficients, and arbitrarily set it to 1, or to any constant. I'd pick a==1, which is as good as any other. So your problem now reduces to something like this:
dy/dt + b*y = c*dx/dt + d*x
Next, although we don't have your data in hand to show how it might work, you have data of the form of a list of values for t, as well as x and y at each point in time.
So just interpolate x(t) and y(t) as splines. Then use them to infer the values of b, c, and d. Assuming t,x, and y are vectors, it would look like this:
xoft = spline(t,x);
xdot = fnder(xoft)
yoft = spline(t,y);
ydot = fnder(xoft)
A = [-y(:),fnval(xdot,t(:)),x(:)];
bcd = A\fnval(ydot,t(:));
bcd will be a vector of length 3, contining the values of b, c, and d. Remember that a was 1.
fnval and fnder should be part of the curve fitting toolbox as I recall.

More Answers (1)

darova
darova on 22 Aug 2019
Look like system of equations
It has many solutions. For example d=1:

Categories

Find more on Spline Postprocessing 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!