function [poleV,poleL] = MHP_elektrostatika(Uzly,Segmenty)

nHranic = length(Segmenty);
poleV = cell(nHranic,nHranic);
poleL = cell(nHranic,nHranic);

for s=1:nHranic
    ns = size(Segmenty{s},2);
    
    for t=1:nHranic
        nt = size(Segmenty{t},2);
        
        V = zeros(ns,nt);
        L = zeros(ns,nt);
        
        for i=1:ns
            Uzlysi = Uzly(:,Segmenty{s}(:,i));
            xsi = sum(Uzlysi,2)/2;
            delkasi = norm(Uzlysi(:,2)-Uzlysi(:,1));
            nsi = ( Uzlysi(:,2)-Uzlysi(:,1) ) / delkasi;
            nsi = [nsi(2);-nsi(1)];                         % Zapomnel jsem prehodit slozky
            
            for j=1:nt
               Uzlytj = Uzly(:,Segmenty{t}(:,j));
               ytj = sum(Uzlytj,2)/2;
               delkatj = norm(Uzlytj(:,2)-Uzlytj(:,1));
               
               if s~=t || i~=j
                    V(i,j) = -(1/(2*pi)) * log(norm(xsi-ytj)) * delkatj;
                    L(i,j) = -(1/(2*pi*norm(xsi-ytj)^2)) * (xsi-ytj)'*nsi *delkatj;
               else
                   V(i,j) = -(1/(2*pi)) * ( log(delkatj/2) - 1) * delkatj;
                   L(i,j) = 0;
               end
               
            end
            
        end
        
        poleV{s,t} = V;
        poleL{s,t} = L;
        
    end
    
end