Uploaded by Shume Birmeji

nd

advertisement
% It calculates ODE using Runge-Kutta 4th order method
clc; f=@ (x,y) x.*(y.*(y.^2); x=1;
y=1;
h=0.1;
Y=1.5;
While X-x>=(-10)
fprint('value of y at x = %0.2f is %f \n',x,y) ;
k1=h.*f(x,y);
k2=h.*f(x+h/2,y+k/2);
k3=h.*f(x+h/2,y+k/2);
k4=h.*f(x+h/2,y+k2/2);
k=(k1+2.*k2+2.*k3+k4)./6;
x=x+h; y=y+k;
end
Download