www.pudn.com > yuyinxinhaochulisuanfa.rar > music.m


function [P,f]=music(R,M,Npoints) 
% Frequency estimate via the MUSIC eigenvector method 
%    [P,f]=music(R,M,Npoints) returns the pseudo spectrum of a autocorrelation 
%    matrix R in the vector P and Npoints-point frequency vector f. M is the  
%    number of complex sinusoids in the signal which constructs the auto- 
%    correlation matrix. 
% 
% See also : ACORMX, MVDR 
 
% Copyright by Zhilin Zhang, Hanlin Laboratory 
% $ Revision: 1.1 $  $ Date: 2003/04/04  11:16 $  
 
%   References: 
%     [1] 胡广书,数字信号处理——理论、算法与实现,清华大学出版社,1997 
     
 
 
% get dimension of R 
dims=size(R(:,1));     
dim=dims(1); 
 
% check whether the input arguments are correct  
if M>=dim  
    error('The dimension of autocorrelation matrix should greater than the number of frequencies\n'); 
end 
 
% find eigenvectors related to the fewer M eigenvalues 
[V,D]=eig(R);                           % get the eigenvectors and eigenvalues 
En=V(:,1:M);                            % get M vetors in noise subspace 
 
deltf=2*pi/Npoints;                     % frequency value between neibor points 
P=zeros(1,Npoints);                     % initialization of P and f 
f=zeros(1,Npoints); 
 
for index=0:Npoints-1 
     
    % design vector a,a=[1 exp(-j*w) exp(-j*w*2) ...exp(-j*w*(dim-1)]'. 
    a=zeros(dim,1); 
    for p=0:dim-1 
        a(p+1)=exp(-j*index*deltf*p); 
    end 
     
    % computer the denominator of Pmusic 
    psum=0; 
    for i=1:M 
        psum=psum+(abs(a'*En(:,i)))^2; 
    end 
  
    P(index+1)=1/psum; 
    f(index+1)=index*deltf; 
end