Adaptive Filters In the Frequency Domain: Difference between revisions

From Class Wiki
Jump to navigation Jump to search
(Created page with 'To come up with a frequency domain example of an adaptive LMS filter, you can have an unknown transfer function in parallel with your adaptive filter, where the output of one is …')
 
No edit summary
Line 3: Line 3:
Here is a MATLAB or octave file that demonstrates the convergence.
Here is a MATLAB or octave file that demonstrates the convergence.


% This script plots a Fourier Series for a Square Wave
% This script plots a Fourier Series for a Square Wave
% GPL License. Look on Google. Any version is fine.
% GPL License. Look on Google. Any version is fine.
% Rob Frohne 2012
% Rob Frohne 2012

clf;
clf;
t=0:.01:10;
t=0:.01:10;
T=2.5
T=2.5
M=50
M=50
sum1=0;
sum1=0;
for m=1:2:M,
for m=1:2:M,
sum1 = sum1+4/m/pi*sin(m*pi/2)*cos(2*pi*m*t/T);
sum1 = sum1+4/m/pi*sin(m*pi/2)*cos(2*pi*m*t/T);
end
end
plot(t,sum1,'b-',t(1:10:end),sum1(1:10:end),'r*')
plot(t,sum1,'b-',t(1:10:end),sum1(1:10:end),'r*')
title('Fourier Series Representation of a Square Wave')
title('Fourier Series Representation of a Square Wave')
xlabel('time (seconds)')
xlabel('time (seconds)')
ylabel('Function')
ylabel('Function')
grid on;
grid on;
axis([0,10,-2,2])
axis([0,10,-2,2])
legend('Five Terms','Five Terms Sampled')
legend('Five Terms','Five Terms Sampled')
print("squarewave.png","-dpng") % Prints the plot to a png file called squarewave.png
print("squarewave.png","-dpng") % Prints the plot to a png file called squarewave.png

Revision as of 20:53, 26 March 2012

To come up with a frequency domain example of an adaptive LMS filter, you can have an unknown transfer function in parallel with your adaptive filter, where the output of one is subtracted from the other creating an error signal. This is then squared and the steepest descent method is used to find a guess to the LMS error iteratively, after every N point FFT is done and at each frequency. The step size is adjusted to be independent of the amplitude of the input. The result converges nicely. See the derivation on the photo.

Here is a MATLAB or octave file that demonstrates the convergence.

% This script plots a Fourier Series for a Square Wave
%  GPL License.  Look on Google.  Any version is fine.
%  Rob Frohne 2012

clf;
t=0:.01:10;
T=2.5
M=50 
sum1=0;
for m=1:2:M,
sum1 = sum1+4/m/pi*sin(m*pi/2)*cos(2*pi*m*t/T);
end
plot(t,sum1,'b-',t(1:10:end),sum1(1:10:end),'r*')
title('Fourier Series Representation of a Square Wave')
xlabel('time (seconds)')
ylabel('Function')
grid on;
axis([0,10,-2,2])
legend('Five Terms','Five Terms Sampled')
print("squarewave.png","-dpng")  % Prints the plot to a png file called squarewave.png