function konvergenceMKP2d()

i = 2:7;
h = 1./(2.^i);
Nh = length(h);

err = zeros(1,Nh);
for i=1:Nh
    hi = h(i)
    [P,T,ID] = diskretizujObdelnik(1,1,hi);
    m = size(T,2);
    k = ones(1,m);
    
    f = zeros(1,m);
    for p=1:m
        Tp = T(:,p);
        Xp = P(:,Tp);
        Tezistep = sum(Xp,2)./3;
        f(p) = 2*pi^2*sin(pi*Tezistep(1))*sin(pi*Tezistep(2));
    end
    
    [A,b] = mkp2d(P,T,ID,k,f);
    uH = A\b;
    N = size(P,2)
    u = zeros(N,1);
    idx = setdiff(1:N,ID);
    u(idx) = uH;
    
    err(i) = sqrt(0.5*pi^2 - uH'*A*uH);
end

plot(h,err)
xlabel('h')
 ylabel('||u-u^h||_a')
 title('Konvergence 2d MKP')