%---------------------------------------------------%
% Euler_method                                       %
%---------------------------------------------------%
% INPUTs (to be provided):
% t1 = starting point
% x1 = initial condition
% tN = end point
% N  = number of steps 
% xp = anonymous function first derivative
% 
% OUTPUTs:
% xt_E = vector solution x(t)
% t    = grid of point t where x(t) has been evaluated

function [xt_E, t] = Euler_method(t1, x1, tN, N, xp)
xt_E(1)=x1;
t=linspace(t1,tN,N);
dt=t(2)-t(1);
for i=1:N-1
    xt_E(i+1)=xt_E(i) + dt*xp(xt_E(i),t(i));
end

end