Sign in

username or email:

password:



Not a member?
Forgot your password?

Search code



Search tips

Ads

See Also

Embedded SystemsFPGA

DSP Code Sharing > NLMS Adaptive filter

NLMS Adaptive filter

Language: Matlab

Processor: Not Relevant

Submitted by Senthilkumar R on Mar 24 2011

Licensed under a Creative Commons Attribution 3.0 Unported License

NLMS Adaptive filter


 

This program is used to implement a Normalized least mean square adaptive filter.

 
%Normalized Least Mean Square Adaptive Filter
%for Echo Cancellation
function [e,h,t] = adapt_filt_nlms(x,B,h,delta,l,l1)
%x = the signal from the speaker
%B = signal through echo path
%h = impulse response of adaptive filter
%l = length of the signal x
%l1 = length of the adaptive filter
%delta  = step size
%e = error
%h = adaptive filter impulse response
tic;
for k = 1:150
    for n= 1:l
        xcap = x((n+l1-1):-1:(n+l1-1)-l1+1);
        yout(n) = h*xcap';
        e(n) = B(n) - yout(n);
        xnorm = 0.000001+(xcap*xcap');
        h = h+((delta*e(n))*(xcap/xnorm));
    end
    eold = 0.0;
    for i = 1:l
        mesquare = eold+(e(i)^2);
        eold = mesquare;
    end
    if mesquare <=0.0001
        break;
    end
end
t = toc; %to get the time elapsed
 
Rate this code snippet:
0
Rating: 0 | Votes: 0
 
   
 
posted by Senthilkumar R



Comments


No comments yet for this code


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )