Code covered by the BSD License  

Highlights from
Runge Kutta 4th order ode

4.7 | 7 ratings Rate this file 109 Downloads (last 30 days) File Size: 1.32 KB File ID: #29851 Version: 1.4

Runge Kutta 4th order ode


Judah S (view profile)


29 Dec 2010 (Updated )

solves ode using 4th order Runge Kutta method

| Watch this File

File Information

This code defines an existing function and step size which you can change as per requirement.

P.S: This code has no new feature compared to existing codes available online. Intention behind posting this very simple code is to help students understand the concept and solve assignments.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
29 May 2015 Shahzaib Asif

function RK4(f,a,x0,y0,h)

% Runge Kutta Method 4th Order
% function @(x,y) e.g. f=@(x,y)(x+y);
% a = the point up to which you obtain the results
% x0 = initial condition of x
% y0 = initial condition of y
% step size

x = x0:h:a;
y(1) = y0;

for i=1:(length(x)-1)

k1 = f(x(i),y(i));
k2 = f(x(i)+0.5*h,y(i)+0.5*h*k1);
k3 = f((x(i)+0.5*h),(y(i)+0.5*h*k2));
k4 = f((x(i)+h),(y(i)+k3*h));

y(i+1) = y(i) + (1/6)*(k1+2*k2+2*k3+k4)*h;



%Shahzaib Asif (zaibi7402)

Comment only
25 Nov 2014 Chris FUNG

clear coding

13 Mar 2013 Christoph  
04 Oct 2012 Ying

Ying (view profile)

04 Oct 2012 Ying

Ying (view profile)

Very good to learn. Thanks.

05 Feb 2012 Arun

Arun (view profile)

29 Mar 2011 Pi Ting

excellent work

02 Jan 2011 Ido

Ido (view profile)

Excellent program,
very helpful.

25 Jan 2012 1.1

Nothing much

16 Jan 2013 1.4

Just an update

Contact us