% Programming and Numerical Methods
% MSc in Computational and Applied Physics

% Code 20: Explicit Euler ODE solver
% A. Meseguer (2007)

% On input: fut (vector field to be called f(z))
%               z = [u_1 ; u_2 ; ... u_N ; t]
%           u0 (initial condition u0(N,1))
%           k  (time step)
%           T  (integration time) 
% On output: t (array of time grid)
%            u (array of v_k's)


  function [t,u] = expleuler(fut,u0,k,T)

  t = [0] ; u = [u0] ; time = 0 ;

  while time < T
   z = [u(:,end) ; t(end)] ;
   u = [u , u(:,end) + k*feval(fut,z)] ;
   time = time + k ; t = [t time] ;
  end  

  
  
