Sign in

username or email:

password:



Not a member?
Forgot your password?

Search code



Search tips


See Also

Embedded SystemsFPGA

DSP Code Sharing > Function to perform Adaptive filtering

Function to perform Adaptive filtering

Language: Scilab

Processor: Not Relevant

Submitted by Senthilkumar R on Dec 28 2011

Licensed under a Creative Commons Attribution 3.0 Unported License

Function to perform Adaptive filtering


 

This function performs echo cancellation using NLMS adaptive filter

 
function[y,M] = adapt_filt(xlms,B,h,delta,l,l1)
    //x = the signal from the speaker directly
    //B = the signal thorugh the echo path
    //h = impulse response of adaptive filter
    //l = length of signal 'x'
    //l1 = length of adaptive filter order
    for k = 1:150
        for n = 1:l
            xcap = xlms((n+l1-1):-1:(n+l1-1)-l1+1);
            yout(n) = h*xcap;
            e(n) = B(n)- yout(n);
            xnorm = 0.001+(xcap*xcap');
            h = h+((delta*e(n))*(xcap'));
        end
        eold = 0.0;
        for i = 1:l
            MSE = eold+(e(i)^2);
            eold = MSE;
        end
        if MSE <= 0.0001 then
            break;
        end
    end
    y =  zeros(1,length(e));
    M = zeros(1,length(h));
    y  = e;
    M = h;
endfunction
 
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? )