% Script rk4_test1.m % Compare with ode45 n = input('Enter number of steps: '); f = @(t,x) 1 + x^2 + t^3; [t,x] = rk4(f, [1,2], -4, n); % display last values of t and x disp([t(end),x(end)]); %opts = odeset('RelTol', 1e-6, 'AbsTol', 1e-6); %[tt,xx] = ode45(f, [1,2], -4, opts); %plot(t,x, '-', tt, xx, '-')