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


function [Pxx,f]=arrsp(A,delt,N,varargin) 
% returns the frequency response, namely Pxx,of the AR system  
% and frequency vector f. It also employs in complex signals analysis.  
%  
%  [Pxx,f]=ARRSP(A,delt,N,'half')   or 
%  [Pxx,f]=ARRSP(A,delt,N,'whole')   or 
%  [Pxx,f]=ARRSP(A,delt,N)     or 
%         Pxx <--- N-point complex frequency response 
%         f   <--- N-point frequency vector in radians/sample  
%         A   <--- row complex vector, representing the coefficient of the AR filter  
%           EXAMPLE:  
%                                   delt^2 
%           Pw= ----------------------------------------------------- 
%               |1+a1*exp(-j*w)+a2*exp(-j*2*w)+...+an*exp(-j*n*w)|^2 
%           in this case, A =[a1,a2,a3,...,an]; 
%        delt <--- standard covarance of noise               
%         N   ---> the number of computered points in [0,2*pi) 
%     'whole' ---> return the all points in [0,2*pi) 
%      'half' ---> return the half points in [0,pi), which is default  
 
%  Copyright by the Author: Zhilin Zhang 
%  $ Revision 1.2 $$ Date: 2003/05/25 01:36 $ 
 
% check the number of the input arguments 
if nargin<3 
    error('Too few input arguments'); 
elseif nargin>4 
    error('Too many input arguments'); 
end 
 
%A=conj(A);             % when signal is complex,the step should be taken. 
% computer 
M=length(A);           % length of vector A 
fdelt=2*pi/N;          % frequency value between neibor points 
for m=0:N-1 
    denomi=1; 
    for n=1:M 
        denomi=denomi+A(n)*exp(-j*n*m*fdelt); 
    end 
    Pxx(m+1)=delt^2/(denomi*conj(denomi)); 
end 
f=[0:N-1]*fdelt; 
 
% if the fourth argument is 1, or the fourth argument is NOT determined, 
% then truncation should be apply to the output arguments f and Pxx 
f2=f(1:floor((N+1)/2)); 
Pxx2=Pxx(1:floor((N+1)/2)); 
if nargin==3 | strcmp(varargin{1},'half') 
    Pxx=Pxx2; 
    f=f2; 
end