function Y = euler(fce, x0,xN,h,y0)
%euler - pribliyne reseni dif.rce 1. radu Eulerovou metodou
%priklad volani pro y'=y-exp(x), y(0)=0
%g= @(x,y) y-exp(x);    Y=euler(g,0,2,.2,0)
%reseni=dsolve('Dy=y-exp(t)','y(0)=0')
%y=subs(reseni,[0:.2:2])    %presne hodnoty
%x=0:.2:2; plot(x,Y,'kx',x,y,'k-o'),legend('euler','presne hodnoty')

if xN<x0, error('Konec intervalu je pred zacatkem!'), end
if h<0, error('Krok musi byt kladne cislo!'), end

x=x0:h:xN;  %nezavisle promenna
Y=x;    %priprava

Y(1)=y0;
for i=2:length(Y)   %pro kazdou dalsi hodnotu
    Y(i) = Y(i-1) + h*fce(x(i-1),Y(i-1));   %Eulerova metoda
end