Solving a differential equation
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Andrew Newell
am 11 Mai 2011
I think Matt has a point. As formulated, it looks like an infinite recursion.
Akzeptierte Antwort
Andrew Newell
am 12 Mai 2011
If your equations contain only linear combinations of the derivatives, you could formulate it as a mass matrix problem M(t,y)y' = f(t,y) . For the two equations you have provided in the comment,
dF = - R*dI/u_a;
dI = const2*cosh(insinh*F)*insinh*dF+vor*sinh(insinh*F)*dn*exp(-beta*dEC2);
you could set up the problem as follows:
y = [F; I];
M = [1 - R/u_a; const2*cosh(insinh*F)*insinh 1];
and f(t,y) would output
[0; vor*sinh(insinh*y(1))*dn*exp(-beta*dEC2)]
See the ode45 documentation for how to include a mass matrix.
(edited to include the relevant part of betlor5's comment)
0 Kommentare
Weitere Antworten (5)
Andrew Newell
am 11 Mai 2011
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
0 Kommentare
Andrew Newell
am 11 Mai 2011
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 Kommentare
Andrew Newell
am 11 Mai 2011
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
am 12 Mai 2011
2 Kommentare
Andrew Newell
am 12 Mai 2011
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.
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!