Evolution of coefficients of adaptive LMS filter

4 次查看(过去 30 天)
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