function [tout,xout] = explicit_euler2(fun,t,x0)
% Function to demonstrate the Explicit Euler method for solution of a system of IVP

n = length(x0);

h = t(2)-t(1);
tout = zeros(length(t),1);
tout(1)=t(1);

xout = zeros(length(t),n);
xout(1,:)=x0(:);

for i=1:length(t)-1
    tout(i+1) = tout(i)+h;
    dxdt = fun(xout(i,:),tout(i))';
    xout(i+1,:) = xout(i,:) + dxdt.*h;
end    