patan.gova
Full Member level 3
- Joined
- Dec 19, 2011
- Messages
- 172
- Helped
- 4
- Reputation
- 8
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- 2,776
Hello,
I am confused with selecting the reference signal for the LMS algorithm as it needs two inputs i.e, one the input signal and other reference signal.But I only have a detected pulse signal as input itself containing noise. So,what should I select as my reference signal for such an input signal. Can anyone explain me of how to handle the reference signal for LMS adaptive filtering.As I am planning to apply this LMS for removing motion artifacts in pulse signals.
The below is the code for function :Least mean square having inputs x(reference),d(input),mu_step:filter step size,M:filter length
The needed motion artifacts pulse signal is shown below with every 500 values represent a pulse signal where each 500 values represent 1 sec pulse signal sampled at 500hz at the microcontroller side.
I am confused with selecting the reference signal for the LMS algorithm as it needs two inputs i.e, one the input signal and other reference signal.But I only have a detected pulse signal as input itself containing noise. So,what should I select as my reference signal for such an input signal. Can anyone explain me of how to handle the reference signal for LMS adaptive filtering.As I am planning to apply this LMS for removing motion artifacts in pulse signals.
The below is the code for function :Least mean square having inputs x(reference),d(input),mu_step:filter step size,M:filter length
Code:
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
The needed motion artifacts pulse signal is shown below with every 500 values represent a pulse signal where each 500 values represent 1 sec pulse signal sampled at 500hz at the microcontroller side.
Last edited: