%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This function is an answer to problem 7 on the Euler's method
%  worksheet.  You can use it as a starting point for 
%  implementing Euler's method.
%
%  Input:
%     g - a function of 1 variable
%    Ti - an intial time
%    Tf - a final time
%     N - number of timesteps
%
%  Returns:
%
%    t - an array of N+1 equally spaced times, starting at Ti and ending at Tf
%    y - an array of function values of g at each of the t's.
%
%  Example:
%
%  g = @(x) x.^2 
%  [t,y] =  AlmostEuler(g,0,1,100)
%  plot(t,y) 

function [t,y]=AlmostEuler(g,Ti,Tf,N)
  t = zeros(1,N+1);
  y = zeros(1,N+1);
  h = (Tf-Ti)/N;
  for( k=0:N )
    t(k+1) = Ti+k*h;
    y(k+1) = g(t(k+1));
  end
end
