Evolution of coefficients of adaptive LMS filter
4 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
dm
on 1 May 2011
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 Comment
Paul Fatosin
on 3 Mar 2021
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
See Also
Categories
Find more on Adaptive Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!