MATLAB CODE FOR Runge kutta 4th order

function u = RK4(h,tf,x1,y1)
%to solve the ode for radiation using rk fourth order
I=tf/h;
fh = @ (x , y) (-2.2067)*(10^-12)*(y^4-(81*10^8));
u = y1;
for i = 1:I
k1=h*fh(x1+(i-1)*h,u);

k2=h*fh(x1+(i-1)*h+(h/2),u+(k1/2));

k3=h*fh(x1+(i-1)*h+(h/2),u+(k2/2));

k4=h*fh(x1+(i-1)*h + h,u + k3);

u= u + (1/6*(k1 + 2*(k2 + k3) + k4));

end
u
end

About these ads

1 Comment »

  1. 1
    musa.khosrowshahey Says:

    hello.
    thank you for this site.your site and specially rungue kutta integration help me alot.i wish you be success in your life’
    by regard.


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: