function X = bsub_sys(A,B)
% Finds a matrix X such that A X =B
% where the coefficient matrix  is upper triangular 
% A x = b
% backward substitution
% Input Arguments
% A the coefficient matrix
% B the right hand side matrix
% Output Arguments
% X (so that A X = B)

[mA,nA] = size(A) ;
[mB,nB] = size(B) ;
X = zeros(mA,nB) ;
if mA == nA 
    if nA == mB 
        % dimensions agree
        for k = 1:nB
             X(:,k) = bsub1(A,B(:,k)) ;
        end     
else
        error('wrong dimensions of B') ;
    end    
else
    error('A is not square');
end            

end

