% metodo de Euler modificado (explicito)
function [t,x] = EulerMOD(t0,tf,x0,dxdt,n)

% atribui o valor de n = 100 como padrao
if nargin < 5, n = 10; end

% armazenado as condicoes iniciais
t(1) = t0;
xs   = x0;
x    = x0;

% calculo do passo
h = (tf-t0)/n;

% loop de integracao
for i = 1:n
     dx = feval(dxdt,t(i),xs);
     xs = xs+h*dx;
     t(i+1) = t(i)+h;
     dx1= feval(dxdt,t(i+1),xs);
     xs = xs+.5*h*(dx+dx1);
     x = vertcat(x,xs);
endfor

end