SHARE
TWEET

Metodo de Euler Mejorado

a guest Dec 5th, 2011 198 Never
  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.  
RAW Paste Data
Top