%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
%
%  This function solves the problem A*x=b where A must be a 
%  lower triangular matrix  (L*y=f)
%
%-------------------------------------------------------------------------------
%-------------------------------------------------------------------------------

function x  =  MyLowerSubstitution(A,b)

%--------------------------------  
% Check dimensions of A
%--------------------------------  
n  =  size(A,1);
m  =  size(A,2);
if abs(n-m)>0
  error('The matrix A must be squared')  
end

x    =  zeros(n,1); % inicializamos el vector incógnita
for i=1:n  %  recorremos todas las componentes del vector x
    x(i)  =  b(i);
    for j=1:i-1
        x(i)  =  x(i) - A(i,j)*x(j);
    end
    x(i)    =  x(i)/A(i,i);
end






