function Wort=orthogonalizerows(W,l,m)

if(nargin<3)
    if(size(W,2)<2)
        error('Specify the number of columns and rows');
    else
        l=size(W,1);
        m=size(W,2);
    end
end

if(size(W,1)<2)
    W=reshape(W,l,m);
end

Wort = real((W*W')^(-0.5))*W;