Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rk = RK_method(x0, y0, h, x)
- f = @(x, y) (-2 * x ^ 3) + (12 * x ^ 2) - (20 * x) + 8.5;
- n = (x - x0) / h;
- for i = 1 : n
- k1 = h * f(x0, y0);
- k2 = h * f(x0 + h / 2, y0 + k1 / 2);
- k3 = h * f(x0 + h / 2, y0 + k2 / 2);
- k4 = h * f(x0 + h, y0 + k3);
- y0 = y0 + (k1 + 2 * k2 + 2 * k3 + k4) / 6;
- x0 = x0 + h;
- end
- rk = y0;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement