function [A,b] = mkp1d(x,k,f,tau)

n = length(x);
m = n-1;
Avlnka = zeros(n,n);
bvlnka = zeros(n,1);

for p=1:m
    h = x(p+1)-x(p);
    
    Ap = (k(p)/h) * [1,-1;-1,1];
    bp = (f(p)*h/2) * [1;1];
    
    idx = [p,p+1];
    Avlnka(idx,idx) = Avlnka(idx,idx) + Ap;
    bvlnka(idx) = bvlnka(idx) + bp;
end
bvlnka(n) = bvlnka(n) - tau;

idx = 2:n;
A = Avlnka(idx,idx);
b = bvlnka(idx);