Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Metodo de Euler Mejorado

By: a guest on Dec 5th, 2011  |  syntax: MatLab  |  size: 0.24 KB  |  hits: 182  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function R = EulerM(a, b, M, y_0)
  2.  
  3. h = (b - a) / M;
  4.  
  5. Y = zeros(1, M+1);
  6. Y(1) = y_0;
  7. T = a:h:b;
  8.  
  9. for i = 1:M
  10.     Y(i + 1) = Y(i) + h * f(T(i), Y(i));
  11.     Y(i + 1) = Y(i) + h / 2 * ( f(T(i), Y(i)) + f(T(i+1), Y(i+1)));
  12. end
  13.  
  14. R = T' Y';
  15.