function [] = euler()
%EULER Eulersches Polygonzugverfahren fuer y'(t) = y(t), y(0) = 1

close all
help euler

dt = input(' dt [0.2]: ');
if isempty(dt)
   dt = 0.2;
end

tmax = 2.0;

figure(1)
axis([0 tmax 0 exp(tmax)])
hold on

% Anfangsbedingung -----
t = 0.0;
y = 1.0;
% Euler-Schritte -------
while t <= tmax
      plot(t,y,'+r','Markersize',10,'Linewidth',1.6)
      y = y + dt*f(t,y);
      t = t + dt;
end
% ----------------------

t = linspace(0,tmax);
plot(t,exp(t),'-b')
hold off
title(['Euler-Verfahren: y''(t)=y(t), y(0)=1, \Deltat = ' num2str(dt)],...
       'FontSize', 18)
xlabel('t', 'FontSize', 18)
ylabel('y(t)', 'FontSize', 18)
set(gca, 'FontSize', 18)
box on
print -depsc euler.eps

%---------------------
function dydt = f(~,y)
dydt = y;
%---------------------