Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [t,y]=runge_hutta(inter,y0,n)
- t(1)=inter(1);
- y(1)=y0;
- h=(inter(2)-inter(1))/n;
- for i=1:n
- t(i+1)=t(i)+h;
- y(i+1)=rungestep(t(i),y(i),h);
- end
- plot(t,y)
- function y=rungestep(t,y,h)
- s1=ydot(t,y);
- s2=ydot(t+h*y/2+h*s1/2);
- s3=ydot(t+h*y/2+h*s2/2);
- s4=ydot(t+h*y+h*s3);
- y=y+h(s1+2*s2+2*s3+s4)/6;
- function z=ydot(t,y)
- z=t^3/y^2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement