1. Matlab code 1

ode23
ode45

2. Matlab code 2

clear
clc
% Rungekutta

syms x y

f = input('Enter the slope:');
x0 = input('Enter the initial value of x:');
y0 = input('Enter the initial value of y:');
n = input('Enter the value of y to find:');
h = (n-x0)/100;

for i=1:100
	k1 = h * subs(f,{x,y},{x0,y0});
	k2 = h * subs(f,{x,y},{x0+h/2,y0+k1/2});
	k3 = h * subs(f,{x,y},{x0+h/2,y0+k2/2});
	k4 = h * subs(f,{x,y},{x0+h,y0+k3});
	y0 = y0 + 1/6*(k1+2*k2+2*k3+k4);
	x0 = x0 + h;
end
display(y0);

See also
WikiPedia:Runge–Kutta_methods
4th order Runge-kutta method by python code(http://doswa.com/blog/2009/01/02/fourth-order-runge-kutta-numerical-integration/)
Matlab Source Code Examples(http://www.mece.ualberta.ca/Courses/mec390/390code/examples.htm)

Retrieved from http://memorecycle.com/w/wiki.php/RungeKuttaMethod
last modified 2016-03-04 23:10:15