Coupled Differential Equations - derivatives on both sides of equations

4 views (last 30 days)
I am trying to solve two coupled differential equations, but I cannot seem to figure out how to get into a form that can be solved with an ode solver. Specifically, I can't get all the derivatives to the left hand side of the equations.
The equations are:
dx/dt=[-1.005*x+0.0000265*dy/dt+0.01*y+f(t)*g1(x,t)]*1/(0.000053+g1(x,t))
dy/dt=[-0.872*y+0.0000265*dx/dt+0.01*x-f(t)*g2(y,t)]*1/(0.000053+g2(y,t))
Where:
f(t)=44100*cos(1.48-377*t)-3888*exp(-33.3*t)
g1(x,t)=24800/(126+.55*abs(117*sin(377*t-1.48)-117*sin(-1.48)*exp(-t/0.03)-x)*240)^2
g2(y,t)=24800/(126+.55*abs(117*sin(377*t-1.48)-117*sin(-1.48)*exp(-t/0.03)+y)*240)^2
Any help would be greatly appreciated.

Accepted Answer

Andrew Newell
Andrew Newell on 27 Aug 2017
Edited: Andrew Newell on 27 Aug 2017
Let's simplify things a little bit so we can better see what is going on. Let
Y = [x; y];
G1(t,Y) = 0.000053+g1(Y(1),t);
G2(t,Y) = 0.000053+g2(Y(2),t);
Then a little rearrangement gives
G1(t,Y)*(d/dt)Y(1) - 0.0000265*(d/dt)Y(2) = F1(t,Y)
G2(t,Y)*(d/dt)Y(2) - 0.0000265*(d/dt)Y(1) = F2(t,Y)
where F1(t,Y) and F2(t,Y) bundle all the remaining terms together. If we now define a "mass matrix"
M(t,Y) = [G1(t,Y) -0.0000265; -0.0000265 G2(2,Y)]
(see the odeset documentation) and a function
F(t,Y) = [F1(Y,t); F2(Y,t)];
then we can define
options = odeset('Mass',M);
and solve something like
[t,y] = ode45(F,tspan,y0)
(see the ode45 documentation). You'll have to define functions F(t,Y) and M(t,Y) to reproduce the above steps. Warning: I have been using a mixture of MATLAB and regular math to keep it simple; you can sort out the details.
  3 Comments
Andrew Newell
Andrew Newell on 28 Aug 2017
I made two modifications to your code. The first is to change the definition of Fn to
function Ydot=Fn(t,Y)
and the second was to change the final command to
[t,y]=ode45(@Fn,t,[0;0],options);
Then it ran fine.
razorfin
razorfin on 28 Aug 2017
Thank you, this has been a huge help to my understanding. Have a great day!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!