Evolution of coefficients of adaptive LMS filter

4 visualizzazioni (ultimi 30 giorni)
Tim
Tim il 30 Apr 2011
Commentato: Paul Fatosin il 3 Mar 2021
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?

Risposte (1)

dm
dm il 1 Mag 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 Commento
Paul Fatosin
Paul Fatosin il 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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by