function vykresliPoleNaboju(polohy,naboje,x0,x1,y0,y1,h)

% vykresliPoleNaboju(polohy,naboje,x0,x1,y0,y1,h)
%           vykresli pole n=length(naboje)=size(polohy,2) naboju, kde
%           polohy ... sloupcove pozice naboju,
%           naboje ... velikosti a polarita naboju,
%           x0,x1,y0,y1,h ... specifikace site pro quiver.


n = length(naboje);

x = x0:h:x1;
y = y0:h:y1;
[X,Y] = meshgrid(x,y);
EX = zeros(size(X));
EY = zeros(size(Y));
M = 1e-6*ones(size(X));

epsilon0 = 8.854e-12;

for i=1:n
    poloha = polohy(:,i);
    q = naboje(i);
    
    vzdalenost2 = (X-poloha(1)).^2+(Y-poloha(2)).^2;
    EX = EX + (q/(4*pi*epsilon0)) .* (X-poloha(1)) ./ max(sqrt(vzdalenost2.^3),M);
    EY = EY + (q/(4*pi*epsilon0)) .* (Y-poloha(2)) ./ max(sqrt(vzdalenost2.^3),M);
end


E = sqrt(EX.^2+EY.^2);
EX = EX ./ E;
EY = EY ./ E;

contour(X,Y,E)
hold on
quiver(X,Y,EX,EY)
hold off
axis image
