You are on page 1of 1

PROGRAM ON RUNGE KUTTA 2ND ORDER METHOD: clc; x0=input('Enter the value of x0:'); y0=input('Enter the value of y0:');

xg=input('Enter the value of xg:'); h=input('Enter the value of h:'); n=(xg-x0)/h; for i=1:n x1=x0+h; k1=h*(x0+y0); k2=h*((x0+h)+(y0+k1)); k=(k1+k2)/2; y1=y0+k; x0=x1; y0=y1; end fprintf('Yg=%f', y1); OUTPUT: Enter the value Enter the value Enter the value Enter the value Yg=1.242050 of of of of x0:0 y0:1 xg:0.2 h:0.1

You might also like