0% found this document useful (0 votes)
62 views

Lms PDF

The document describes an issue implementing an adaptive filter using the LMS algorithm. The code provided terminates with an "error Index exceeds matrix dimensions" error when calculating the error term E(k). The author is using noise as the desired response and seeks advice on resolving the error.

Uploaded by

anduva8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Lms PDF

The document describes an issue implementing an adaptive filter using the LMS algorithm. The code provided terminates with an "error Index exceeds matrix dimensions" error when calculating the error term E(k). The author is using noise as the desired response and seeks advice on resolving the error.

Uploaded by

anduva8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

I am trying to design an adaptive filter using the LMS algorithm as

written below. Can anyone advice me on where I'm going wrong. I'm
using noise as the desired response as it is unknown.

I include code which terminates at the line
E(k) =d(k) - A(k-1,:)*X(k,:).'; with the error Index exceeds matrix
dimensions.
Inputs are
x=wavread('sound.wav')%sound file
d=rand(1000,1)%to simulate noise
mu=0.001
nord=3
a0=1
%LMS Adaptive filtering using the Widrow-Hoff LMS algorithm.
%---
%USAGE [A,E] =lms(x,d,mu,nord,a0)
%
% x : input data to the adaptive filter.
% d : desired output
% mu : adaptive filtering update (step-size) parameter
% nord : number of filter coefficients
% a0 : (optional) initial guess for FIR filter
% coefficients - a row vector. If a0 is omitted
% then a0=0 is assumed.
%
% The output matrix A contains filter coefficients.
% - The n'th row contains the filter coefficients at time n
% - The m'th column contains the m'th filter coeff vs. time.
% - The output vector E contains the error sequence versus
time.

function [A,E] =lms(x,d,mu,nord,a0)
X=convm(x,nord);
[M,N] =size(X);
if nargin <5, a0 =zeros(1,N); end
a0 =a0(:).';
E(1) =d(1) - a0*X(1,:).';
A(1,:) =a0 +mu*E(1)*conj(X(1,:));
if M>1
for k=2:M;
E(k) =d(k) - A(k-1,:)*X(k,:).';
A(k,:) =A(k-1,:) +mu*E(k)*conj(X(k,:));
end;
end;
Thanks in advance

You might also like