function r = rk(a, b, h, f)n = (b-a)/h;t = a;w = 1/3;for i = 1:n kone = h * f(t,w); ktwo = h * f(t+h/2,w+kone/2); kthr = h * f(t+h/2,w+ktwo/2); kfou = h * f(t+h,w+kthr); w = w + (kone + 2*ktwo + 2*kthr + kfou)/6; t = a + i*h; fprintf('w=%f t=%f\n',w,t);endr = 0;
why does it always give me an error? my other function has exactly the same structure as this one and it works!!!!
Best Answer