% This is a function program of root music algrithm. The input is
% the data matrix from the array and number of the coming signals. 
%  The output is the estimation of the angles.
% a: the array matirx of a single angle.
% Pmu: the null-spectrum of this algrithm
% E,U,V:singular values and associated left- and right- singular vector
function [Theta,musrts,mrt]=rootmu(P,Uo)
ij=sqrt(-1);
[L,X]=size(Uo);
%[U,E,V]=svd(Y);
%Uo=U(:,P+1:L);
%
coefs=[]; 
enent=Uo*Uo';
for i=-L+1:L-1
	coefs(i+L)=sum(diag(enent,i));
end
musrts=sort(roots(coefs')); musrt=musrts(L-1:-1:1);
mrt=musrt(1:P);
Theta=sort(asin(angle(musrt(1:P))/pi))'; 

