solving an implicit ordinary differential equation

조회 수: 13 (최근 30일)
Nariman Mahabadi
Nariman Mahabadi 2019년 1월 11일
댓글: David Goodmanson 2019년 1월 14일
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 ?

답변 (1개)

David Goodmanson
David Goodmanson 2019년 1월 12일
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
Nariman Mahabadi
Nariman Mahabadi 2019년 1월 14일
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 2019년 1월 14일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by