www.pudn.com > GengerateCrossCorreslation.rar > TDOA.m


 
    function Jn_l=lms(miu,M,N,w0) 
%read speech  it is a column vector; 
r=wavread('D:\Program Files\MATLAB704\work\02.wav',300); 
% cut the former 3000 points; 
 
a=r(1:300,1)';x2=zeros(1,300);w=zeros(1,100);e=zeros(1,100);j=zeros(1,100); 
x1=a;% r is the input noisy signal vector; 
for n=1:290 
    x2(n+10)=a(n);% D is the TDOA 
end 
x2=x2;% x1,x2 are the signals received 
 
u=0.005; % step size 
for n=1:100   %  select 1000 poiont of the data 
    e(n)=x2(n+100)-w(n)*x1(n+100); 
    w(n+1)=w(n)+u*e(n)*x1(n+100); 
    j(n)=abs(e(n))^2; 
end; 
    figure;  plot(w,'r'); 
    figure; plot(j,'b');  
  
 
%M=8;N=200;miu=0.005;w0=1*pi; 
 
e_sum=zeros(1,N); 
w_sum=zeros(M,N+1); 
 
for l=1:100 
     
    n=1:N; 
    v=sqrt(0.1)*randn(1,N); 
    un=exp(j*pi*n-j*pi)+exp(j*w0*n-j*0.79*pi)+v; 
 
    u=[zeros(1,M) un]; 
    w=zeros(M,1); 
    for i=1:N 
        u_t=conj(fliplr(u(i:M+i-1)')); 
        e(i)=u(M+i)-w(:,i)'*u_t; 
        w(:,i+1)=w(:,i)+miu*u_t*e(i)'; 
    end 
         
    w_sum=w_sum+w; 
    e_sum=e_sum+abs(e).^2; 
     
end 
 
w_mean=w_sum./100; 
e_mean=e_sum./100; 
Jn_l=e_mean;  
 
plot(n,Jn_l) 
 
a=-conj(w_mean(:,200)); 
wn=0:0.01:2*pi; 
a=a';x=[1:M]; 
H=abs(1+a*exp(-j*x'*wn)).^2; 
Pxx=1./H; 
figure(2);plot(wn,abs(Pxx));