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!