Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function [t,u]=eestab(f,t0,T,y0,df,alpha,hmax)
  2. t(1)=t0;
  3. u(1)=y0;
  4. der=df(t0,y0);
  5. if abs(der)<=1.e-3
  6. h=hmax;
  7. else
  8. h=min(hmax,2*alpha/abs(df(t0,y0)));
  9. end
  10. t(2)=t(1)+h;
  11. n=1;
  12. while t(n+1)<=T
  13. u(n+1)=u(n)+h*f(t(n),u(n));
  14. n=n+1;
  15. der=df(t(n),u(n));
  16. if abs(der)<=1.e-3
  17. h=hmax;
  18. else
  19. h=min(hmax,2*alpha/abs(df(t(n),u(n))));
  20. end
  21. t(n+1)=t(n)+h;
  22. end
  23. if t(n)<T
  24. t(n+1)=T;
  25. h=T-t(n);
  26. u(n+1)=u(n)+h*f(t(n),u(n));
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement