function x = bsub1(A,b)
% Finds the solution vector of a system of linear equations
% where the coefficient matrix  is upper triangular 
% A x = b
% backward substitution
% Input Arguments
% A the coefficient matrix
% b the right hand side vector 
% Output Arguments
% x the solution vector

n = length(b) ;
for i = n:-1:1
    x(i) = b(i) ;
    for j = i+1:n
        x(i) = x(i) - A(i,j)*x(j) ;
    end
    x(i) = x(i)/A(i,i) ;
end

end

