  function [t,y]=Euler(f,tspan,y0,nstep)
% function [t,y]=Euler(f,tspan,y0,nstep)
% Input: f        name of the ODE file.
%        tspan    a vector specifying the interval of integration [ta tb].
%        y0       vector of initial conditions.
%        nstep    number of steps.
% Output:[t,y]    solution matrix y, where each row corresponds to an instance 
%                 in the column vector t.

 if(size(y0,2)>1) y0=y0'; end %Column vector
 t0= tspan(1); tn = tspan(2); 
 h = (tn-t0)/nstep;
 t = [t0:h:tn];
 nOfUnk = length(y0);
 y = [y0';zeros(nstep,nOfUnk)];
 yi = y0;
 for i=1:nstep
   ti = t0 + (i-1)*h;
   yi = yi + f(ti,yi)*h;
   y(i+1,:)=yi'; %Storage not needed for the computation of y(tn)
  end
