# Evolution of coefficients of adaptive LMS filter

5 ビュー (過去 30 日間)
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 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 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

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!