SHARE
TWEET

Untitled

a guest May 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % Runge-Kutta av orden 4.
  2. function x = rk4(T,N)
  3.     f = @(t,x) 2*x/(t+1)-x^2/(t+1)^3;
  4.     h = T/N;
  5.     x = 1;
  6.     for n = 0:N-1
  7.             k1 = h*f(n*h, x);
  8.             k2 = h*f(n*h+ h/2, x+k1/2);
  9.             k3 = h*f(n*h+ h/2, x+k2/2);
  10.             k4 = h*f(n*h+ h, x+k3);
  11.         x= x+1/6*(k1+2*k2+2*k3+k4);
  12.     end
  13. end
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top