How can I solve a system of ODE's, in which the equations have a dependency on time, as well as the other ODEs?

3 visualizzazioni (ultimi 30 giorni)
I have a system of ODE's that depend on time, as well as the other ODE's. I have searched the forum something of this type and can't quite seem to find something similar. For example, how could I solve something of the form:
I have shortened the equations significantly as I am after the process of how to solve these ODEs (and the equations I am attempting to solve are much longer). I am familiar with ODE 45, but something about the system only being first order while the derivatives being contained in the other equation, and the independant variable appearing in the equations is throwing me off. Thank you very much for any help.

Risposte (2)

Alan Stevens
Alan Stevens il 12 Apr 2021
By substituting the first into the second and then the second into the third you can write the last two as:

James Tursa
James Tursa il 12 Apr 2021
Just code it up as it appears using a 3-element state vector, where the elements are defined as follows
y(1) = x
y(2) = y
y(3) = z
E.g.,
function dy = myderiv(t,y)
dxdt = y(1) * (t + y(2)) - y(1)^2;
dydt = dxdt / y(3) - y(2);
dzdt = y(3) * (dydt + y(2)/t);
dy = [dxdt;dydt;dzdt];
end
Use this function with ode45( ). Note that you are dividing by z and t, so you can't initialize either of those to 0.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by