recurrsive least square filter(RLS)



recurrsive least square filter(RLS) in matlab



function [W,e]=rls(x,d,N,delta,lambda,I,Wini,Pini,Xini)

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

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

if (~exist('Pini'))
P = diag((ones(N,1)/delta));
else
if ((size(Pini,1)~=N) | (size(Pini,2)~=N))
error('Initial inverse must me square NxN');
end
P = Pini;
end
Lx = length(x);
[m,n] = size(x);
if (n>m)
x = x.';
end

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

for j=1:itr
for i = 2:Lx
X = x(i+N-1:-1:i);
Pi = P*X;
k = Pi/(lambda + X'*Pi);
y(i,1) = W'*X;
e(i,1) = d(i,1) - y(i,1)
W = W + k*e(i,1)
P = (P - (k*(X')*P))/lambda;
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.

0 comments