Evolution of coefficients of adaptive LMS filter

조회 수: 4 (최근 30일)
Tim
Tim 2011년 4월 30일
댓글: Paul Fatosin 2021년 3월 3일
Hello everybody!
For my project, I'm designing an adaptive filtering for a ECG signal that is corrupted by movement artefacts.
I'm using the build-in Matlab function 'adaptfilt.lms'. Everything works fine, but I need the evolution of the filter coefficients of the adaptive filter. The function 'coefficients' only returns the latest set of coefficients, so that function has no use for me. I tried to edit the original code of the adaptfilt.lms but it seems like it is protected.
My question is: Is there a function that shows the evolution of the filter coefficients of the adaptive filter? Or how can I modify the existing code?

답변 (1개)

dm
dm 2011년 5월 1일
Quickly written based on LMS algorithm at Wikipedia (which I think originate from Haykin's "Adaptive Filter Theory 4th Ed.")
function [w,y,e,W] = LMS(x,d,mu_step,M)
N = length(x); % number of data samples
y = zeros(N,1); % initialize filter output vector
w = zeros(M,1); % initialize filter coefficient vector
e = zeros(N,1); % initialize error vector
W = zeros(M,N); % filter coefficient matrix for coeff. history
for n = 1:N
if n <= M % assume zero-samples for delayed data that isn't available
k = n:-1:1;
x1 = [x(k); zeros(M-numel(k),1)];
else
x1 = x(n:-1:n-M+1); % M samples of x in reverse order
end
y(n) = w'*x1; % filter output
e(n) = d(n) - y(n); % error
w = w + mu_step*e(n)'*x1; % update filter coefficients
W(:,n) = w; % store current filter coefficients in matrix
end
  댓글 수: 1
Paul Fatosin
Paul Fatosin 2021년 3월 3일
I get "Array indices must be positive integers or logical values." and refers me to the " x1 = x(n:-1:n-taps+1); % M samples of x in reverse order" line.
What am I doing wrong?
Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Adaptive Filters에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by