Solving a differential equation
이전 댓글 표시
Hello,
I am working at a mathematical problem and I wanted to solve it numerically through MATLAB. The equation has the form:
y'(t) = g(t,y(t)) - a y(t)
and
g(t,y(t)) = b sinh[(g(t-dt, y(t-dt))] y(t) + c
with a,b,c in R.
I already tried using the ode and dde function in MATLAB without luck. Therefore I hope you can help me with the implementation in the code.
댓글 수: 4
Matt Tearle
2011년 5월 10일
Please show what you've done and explain what the problem ("without luck") is.
Also, am I correct in interpreting the equation as being defined implicitly (g(t,y) is a function of g(t-dt,y(t-dt)))? I don't really understand how that would work.
John D'Errico
2011년 5월 11일
Matt - that is a variation of a DDE, a delayed differential equation.
Andrew Newell
2011년 5월 11일
I think Matt has a point. As formulated, it looks like an infinite recursion.
Andrew Newell
2011년 5월 12일
Thanks to whoever corrected the spelling of the title!
채택된 답변
추가 답변 (5개)
Andrew Newell
2011년 5월 11일
1 개 추천
I have been floundering a bit with this problem, but now I see what you need: a variable
z = [y; g]
with
y'(t) = (g-a)*y(t)
g'(t) = df(t)/dt * y(t)
g(0) = c
The function f is something like what you currently would call b sinh[(g(t,y)].
Note that this new system is a set of ordinary differential equations, so you could use the odexx functions.
EDIT: In terms of z,
z_1'(t) = (z_2-a)*z_1
z_2'(t) = df(z_1)/dt * z_1
z_2(0) = c
Andrew Newell
2011년 5월 11일
If I understand your question, you have a delay differential equation with one variable y(t), and your equation has the form y'(t) = f( y(t), y(t-t1) ), so it should input a scalar for y(t) and another for y(t-1) (the variables y and Z). Instead, you input vectors of length 2 and return a 2-vector for y'(t).
EDIT: For clarity, it might help to rewrite your function as follows:
function d = ddeg(~,y,ylag)
The tilde is used in recent versions of MATLAB to indicate that the variable is not used. If your version of MATLAB objects, put the t back in.
EDIT 2: I'm not sure that your definition of the function g makes sense. If
g(t,y(t)) = b sinh[(g(t-dt, y(t-dt))] y(t) + c
then
g(t-dt,y(t-dt)) = b sinh[(g(t-2*dt, y(t-2*dt))] y(t-dt) + c
and so on forever. How could you evaluate g?
댓글 수: 3
betlor5
2011년 5월 11일
Andrew Newell
2011년 5월 11일
You don't need to pass on g. The purpose of ddeg is to calculate y'(t) and get the next y(t). The solver takes care of the details.
betlor5
2011년 5월 11일
betlor5
2011년 5월 12일
0 개 추천
댓글 수: 2
Andrew Newell
2011년 5월 12일
It could be g'(t) = f'(t) * y'(t). My answer above is just a sketch; I can't tell exactly what the right form is without the original equations. Yes, I think that if you can calculate g'(t), you should make g a component of the y vector.
I don't see the problem with solving 8 differential equations. People solve systems of thousands using MATLAB. And I really don't see how passing g as a variable makes it any simpler.
betlor5
2011년 5월 12일
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!