Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Runge-Kutta av orden 4.
- function x = rk4(T,N)
- f = @(t,x) 2*x/(t+1)-x^2/(t+1)^3;
- h = T/N;
- x = 1;
- for n = 0:N-1
- k1 = h*f(n*h, x);
- k2 = h*f(n*h+ h/2, x+k1/2);
- k3 = h*f(n*h+ h/2, x+k2/2);
- k4 = h*f(n*h+ h, x+k3);
- x= x+1/6*(k1+2*k2+2*k3+k4);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement