%% Euler method
% Solve the IVP y'(x)=f(x,y) with y(y0)=x0. The function f is given as a
% symbolic function.
% Given: step size h and number of steps. 

function [xE,yE] = Euler_H(f,x0,y0,h,N)

if length(h) == 1
    h = h*ones(1,N);
end
xE = zeros(1,N+1); yE = zeros(1,N+1);   % Initialization
xE(1) = x0; yE(1) = y0;                 % Initial condition


for i=1:N                               % For loop over the steps
    xE(i+1) = xE(i)+h(i);                  % Next x
    yE(i+1) = yE(i)+h(i)*f(xE(i),yE(i));   % Euler iteration - next y
end