n = 50;
h = 1/(n+1);

A = zeros(n,n);
for i=1:n
    for j=1:n
        if i == j
            A(i,j) = -2;
        elseif abs(i-j) == 1
            A(i,j) = 1;
        end
    end
end
A = A/h^2;
b = ones(n,1);
x = A\b;

plot([0:h:1],[0; x; 0])