solving an implicit ordinary differential equation

6 vues (au cours des 30 derniers jours)
Nariman Mahabadi
Nariman Mahabadi le 11 Jan 2019
I have to differential equations and I'm trying to solve these using ode45 or ode15 in Matlab:
dP/dt= f(R,P,dR/dt)
dR/dt=f(R,P)
any idea how I can solve these two equations ?

Réponses (1)

David Goodmanson
David Goodmanson le 12 Jan 2019
Hi Nariman,
I assume that the two functions you show as f are not the same function, so I will denote the second one as g. And you don't say whether P and R are scalars, so I assume they are column vectors of size m and n respectively. The input to ode45 is a column vector [P ; R] of length m+n, and so is the output vector [dP/dt ; dR/dt]. You have
dP/dt = f(R,P,dR/dt)
dR/dt = g(P,R)
which, using substitution and composition of functions is the same as
dP/dt = f(R,P,g(P,R))
dR/dt = g(P,R)
so the output d/dt vector is determined by these equations.
  2 commentaires
Nariman Mahabadi
Nariman Mahabadi le 14 Jan 2019
Hi David,
Thank you for the answer. The equations are:
dP/dt=6R/(PR^3) - 3P/R*dR/dt
dR/dt=R/4*(P-2/R)
the Initial conditions: P=10; and R=20;
The time period to solve these equations is [0 100]
So is this the correct form?
f = @(t,x) [6*x(2)/(x(1)*x(2)^3) - 3*x(1)/x(2)*dR/dt ; x(2)/4*(x(1)-2/x(2))]
[t,xa] = ode45(f,[0 100],[10 20]);
David Goodmanson
David Goodmanson le 14 Jan 2019
Hi Nariman, you should run this and see. It's a valuable thing to do because the error message is very informative, and otherwise you are operating in a vacuum.
When you run it, you will find that f has no way of knowing what dR/dT is, since it is not supplied on input. (Since it is in dR/dT form and not denoted as a single variable such as dRdT, f does not know what either of dR or dT are. So it coughs up and error message about dR). In place of dR/dT you need to insert the equivalent expression in terms of x(1) and x(2), but you already have that.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by