Fourth-order Runge–Kutta method (RK4) collapses after a few iterations
问题 I'm trying to solve: x' = 60*x - 0.2*x*y; y' = 0.01*x*y - 100* y; using the fourth-order Runge-Kutta algorithm. Starting points: x(0) = 8000, y(0) = 300 range: [0,15] Here's the complete function: function [xx yy time r] = rk4_m(x,y,step) A = 0; B = 15; h = step; iteration=0; t = tic; xh2 = x; yh2 = y; rr = zeros(floor(15/step)-1,1); xx = zeros(floor(15/step)-1,1); yy = zeros(floor(15/step)-1,1); AA = zeros(1, floor(15/step)-1); while( A < B) A = A+h; iteration = iteration + 1; xx(iteration)