function prikladMKP1d()

E1 = 1;
E2 = 5;
f = 10;
a = 0.5;
l = 1;
tau = 0.1;

figure
hold on
for n=12:2:20
    
    % diskretizace
    h = l/n;
    x = h:h:l;

    idxa = find(abs(x-a)<h/1000);
    E = E1*ones(1,n);
    E(idxa+1:n) = E2;
    
    A = sparse(n,n);
    b = zeros(n,1);    
    for i=1:n
        if i<n
            A(i,i) = (E(i)+E(i+1))/h;
        else
            A(n,n) = E(n)/h;
        end
        if i>1
            A(i,i-1) = -E(i)/h;
            A(i-1,i) = A(i,i-1);
        end
        
        b(i) = f*h;
        if i==n
            b(i) = b(i) + tau;
        end
    end
    
    u = A\b;
    
    plot([0,x],[0,u'])

    pause
    
end
