How do I type the code using Runge-Kutta?
显示 更早的评论
Write a function that implements the classical Runge-Kutta fourth-order method for the case of a system of four equations with four unknowns. Use this function to solve the system:
x' = u; y' = v; u' = −2x + (3/2)y; v '= (4/3)x − 3y
subject to the initial conditions x(0) = −1, y(0) = 4, u(0) = 1, v(0) = 1. Use a step size ∆t = 0.01 and (a) Plot the values of the four variables as a function of time, each on a different plot, up to t = 15. (b) Plot u(t) (vertical axis) versus x(t) (horizontal axis) for the same range in t.
1 个评论
Steven Lord
2018-12-10
Since this sounds like a homework assignment, if you show us what you've written to try to solve the problem and ask a specific question about where you're having difficulty we may be able to offer some guidance.
If this isn't a homework assignment, just use the ODE solvers included in MATLAB, like ode45. Or if it is a homework assignment, use the results from ode45 to check your function's answer.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!