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

n = length(x)-1;
Atilda = zeros(n+1,n+1);
btilda = zeros(n+1,1);

for p=1:n
    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];
    Atilda(idx,idx) = Atilda(idx,idx) + Ap;
    btilda(idx) = btilda(idx) + bp;
end

idx = setdiff(1:(n+1),ID);
ustriska = zeros(n+1,1);
ustriska(ID) = uD;
btilda(IN) = btilda(IN) + tau;

A = Atilda(idx,idx);
b = btilda(idx) - Atilda(idx,:)*ustriska;