normalized LMS



normalized least mean square NLMS filter matlab code

function [W,e] = nlms(x,d,N,mu,alpha,I,Wini,Xini)
%x-reference input, here the reference to noise, 'n1'

%d-desired or primary input, here the signal plus noise, 's+no'

%N-no. of taps i.e., filter length or order

%mu-step-size or convergence parameter usually
%(i) 0
%(ii) 0
%(iii) 0
%(iv) 0
%lower the mu value, better the noise removal but slower the speed of
%convergence and VICE VERSA. Try changing dynamically mu according to (i)
%or (ii) or (iii) for every iteration. Add a small positive value <>
%denominator of (ii) and (iii) in order to avoid division-by-zero in case of zero signal power

%alpha-small positive real value approximately 0

%I-no. of iterations

%Wini-initial weight vector

%Xini-initial state vector i.e., initial values of reference input

%W-final weight vector

%e-error signal e=d-W*x, this is the signal recovered

%Please refer to (1) Adaptive Filter Theory by Simon Haykin (2) PDF file
%attached to this and (3) Adaptive Signal Processing by Widrow and Stearns.

Lx = length(x);
[m,n] = size(x);
if (n>m)
x = x.';
end

if (~exist('I'))
itr = 1;
else
itr = I;
end

if (~exist('Wini'))
W = zeros(N,1);
else
if (length(Wini)~=N)
error('Weight initialization does not match filter length');
end
W = Wini;
end

if (~exist('Xini'))
x = [zeros(N-1,1); x];
else
if (length(Xini)~=(N-1))
error('State initialization does not match filter length minus one');
end
x = [Xini; x];
end

for i = 1:itr
for k = 1:Lx
X = x(k+N-1:-1:k);
y = W'*X;
e(k,1) = d(k,1) - y;
p = alpha + X'*X;
W = W + ((2*mu*e(k,1))/p)*X;
end
end
thumbnail
About The Author

Ut dignissim aliquet nibh tristique hendrerit. Donec ullamcorper nulla quis metus vulputate id placerat augue eleifend. Aenean venenatis consectetur orci, sit amet ultricies magna sagittis vel. Nulla non diam nisi, ut ultrices massa. Pellentesque sed nisl metus. Praesent a mi vel ante molestie venenatis.

1 comments

  1. Can you please post variable step size NLMS algorithm Matlab program in your blog ?

    ReplyDelete