function W = gorth(V)
%
% GORTH(V) performs a Gram-Schmidt orthonormalization on the complex
% matrix V.
%
[M,L] = size(V);
for I1 = 1:L
%  Initialization
   W(:,I1) = V(:,I1);
%  Removing projection of V(:,I1) onto W(:,1),...,W(:,I1-1)
   for I2 = 1:I1-1
      W(:,I1) = W(:,I1) - ( W(:,I2)' * V(:,I1) ) * W(:,I2);
   end
%  Normalization of resulting orthogonal vector
   norm = sqrt( W(:,I1)' * W(:,I1) );
   W(:,I1) = W(:,I1)/norm;
end
