n = 5;
M1 = 0;
alpha = [1 2 3 4];
beta = [1 2 -1 3];
gamma = [0 -1 1 2];
A = zeros(n-1);
for j = 1:n-1
    A(j,j) = beta(j);
    if (j < n-1)
        A(j+1,j) = alpha(j+1);
    end
end
b = transpose(gamma);
b(1) = b(1) - alpha(1)*M1;

X = inv(A)*b