Solve ODE using backward euler's method
116 次查看(过去 30 天)
显示 更早的评论
x' = λ - ρx - βxz;
y' = βxz - δy;
z' = py - cz;
x0=43100; y0 = 0, z0 = 0.0033, λ = 388, ρ = 0.009 δ = 0.18, p = 50000, c = 23, β=3.61e-8
Is there a built-in function in matlab to solve the above non-linear system using the backward euler's method?
0 个评论
采纳的回答
Torsten
2015-12-14
Initialize
x_old = 43100, y_old = 0 and z_old = 0.0033
Compute x_new by solving the nonlinear system of equations
(x_new-x_old)/dt = lambda - rho*x_new - beta*x_new*z_new
(y_new-y_old)/dt = beta*x_new*z_new - delta*y_new
(z_new-z_old)/dt = p*y_new - c*z_new
by fixed-point iteration or with MATLAB's fsolve, e.g.
This gives you the solution for your system at time t=dt.
Set
x_old = x_new, y_old = y_new and z_old = z_new
and solve the above system again for x_new, y_new and z_new.
This gives you the solution at time t=2*dt.
Continue until you reach t=tfinal.
Best wishes
Torsten.
3 个评论
Torsten
2015-12-14
As far as I know, Forward Euler evaluates the right-hand side with the old values:
(x_new-x_old)/dt = lambda - rho*x_old - beta*x_old*z_old
(y_new-y_old)/dt = beta*x_old*z_old - delta*y_old
(z_new-z_old)/dt = p*y_old - c*z_old
Best wishes
Torsten.
更多回答(1 个)
Walter Roberson
2015-12-12
No, there is no built-in function in MATLAB for that.
2 个评论
Walter Roberson
2015-12-13
But perhaps one of the File Exchange contributions would be useful: http://www.mathworks.com/matlabcentral/fileexchange/31427-1st-oder-ode-solver-euler-backward-method-based
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!