Info

This question is closed. Reopen it to edit or answer.

Can someone explain why the error and filtered signals are switching alternatively.

1 view (last 30 days)
Hello,
I have been working out from a longtime on adaptive filtering with leastmean square method but was unable to get the right way for the LMS implementation.
I implemented the following considering each pulse signal has 500 samples.For the first pulse signal(of 500 samples)the reference signal is generated from the lowpass filter of the pulse signal and then using the generated error as reference noise signal for the next pulse signals
P=load('Pulse_signal.mat');
a2=P.a(334:4500,:);
for i=1:500:length(a2)-500
if(i<500)
input=a2(i:i+499,:);
detected(i:i+499,:)=input;
d = fdesign.lowpass('Fp,Fst,Ap,Ast',1.5,8,0.5,20,500);
Hd1 = design(d);
filtered = filtfilt(Hd1.Numerator,1,input);
[w,y,e,W]=simple_LMS1(filtered,input,0.08,5);
e2(i:i+499,:)=e;
y2(i:i+499,:)= y;
else
input=a2(i:i+499,:);
detected(i:i+499,:)=input;
[w,y,e,W]=simple_LMS1(e,input,0.08,8);
e2(i:i+499,:)=e;
y2(i:i+499,:)= y;
end;
end
plot(detected);hold on;plot(e2,'-r');hold on;plot(y2,'-k');
simple_LMS1 fucntion
function [w,y,e,W] = simple_LMS1(x,d,mu_step,M)
N = length(x);
y = zeros(N,1);
w = zeros(M,1);
e = zeros(N,1);
W = zeros(M,N);
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;
e(n) = d(n) - y(n);
w = w + mu_step*e(n)'*x1;
W(:,n) = w;
end
Problem: But the problem is that the output(more or less similar to input) is being alternatively shifted between the error signal and filtered signal as shown in the image below.
Can I know why this is happening.

Answers (1)

Gova ReDDy
Gova ReDDy on 3 Jan 2014
Can someone explain why the error and filtered are switching alternatively after each iteration. Is there something wrong with the code itself .
  6 Comments
Gova ReDDy
Gova ReDDy on 5 Jan 2014
Sorry, Image Analyst I didn't get you.
as he has many video tutorials here .Can I know which one are you referring to me.
Image Analyst
Image Analyst on 5 Jan 2014
When you're using a web browser and the text switches to a different color, like blue, it means that that text is a link. You can put your arrow over that blue text and it will change into a hand. Look in my comment where I put his name. See that it is in a different color? That means it's a link to the video where Doug will tell you how to solve your problem.

Products

Community Treasure Hunt

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

Start Hunting!