Question

LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all close al

implement the LMS algorithm to clean up the signal with noise. Experiment with noise power being stronger than the signal, sa

LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all close al1: Generate signals for testing the LMS Algorithm 1000 Fs Sampling frequency Sample time 1/Fs 10000: = L Length of signal S Time vector (0:L-1) *T ; Sum of a 50 Hz sinusoid and a 120 Hz sinusoid 0.7 sin (2*pi*50*t); inuside X d+ 10 randn (size (t)); Sinusoids 5O0000000L plus noise fiqure (1) plot (Fs*t (1:150),x (1:1500)) title('Signal Corrupted with Zero-Mean Random Noise) xlabel ('time (milliseconds) ') figure (2)iplot (Fst (1:150),d (1:150)) title('Clean Signal') xlabel'time (milliseconds) ') wwwww w Now Apply the LMS in the MATLAB's Command line Example x,d, 0.05, 20, Eat) >> The LMS code is below function [h AA AA h estimated FIR filter y-output signal x-input noisy signal d- desired signal delta step size N-length of FIR filter note please all signals run mysignals.m to generate M=length (x); v= zeros (1, M); h zeros (1.N) for n-N:M some delay to accommodate the adaptation x1- x (n:-1:n-N+1) y (n)-h*x1'; e-d (n)-y (n) h h+deltae*x1; end fiqure (3); plot (Fs t (1:150),y (1:150) ) title('Output Signal after LMS') xlabel('time (milliseconds) ')
implement the LMS algorithm to clean up the signal with noise. Experiment with noise power being stronger than the signal, say 10 times. Discuss the issue of step size as well starting with filter coefficients that are random instead of zero. Plot the short time average-squared error defined below as well as the filter coefficients at the beginning and the end of the run. Desired Signal +1 s(n) Sine wave Output generator xin) šin) Delay D-1 Adaptive FIR filter w(n) Noise generator The ASE is defined as n+K 1 ASE(m) Σ ) K k=n+1 where e (k) is the squared error, mnlK 1 2K. The averaging interval K may be selected to be (approximately) K 10N. The effect of the choice of the step size parameter Aon the convergence rate may be observed by monitoring the ASE(m) For how to use random number generators please go to the MATLAB help manual O
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Main Code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

close all,
clear all,
clc,

Fs=1000;
F=50;
T = 1/Fs;
L=10000;
t=(0:(L-1))*T;

ShowLength=150;
length(t)

d = 0.7*sin(2*pi*F*t);
Noise = rand(size(t)); %Full Scale Noise Input to Filter
x = d + 10*Noise;


subplot(5,1,1); plot(Fs*t(1:ShowLength),d(1:ShowLength)); grid on, title('Original Clean Signal');
subplot(5,1,2); plot(Fs*t(1:ShowLength),Noise(1:ShowLength)); grid on, title('Full Scale Noise Signal');
subplot(5,1,3); plot(Fs*t(1:ShowLength),x(1:ShowLength)); grid on, title('Original Signal Corrupted with Full Scale Zero Mean Random Noise');


Order=31;
h = fir1(Order,0.5); % FIR system to be identified
delta = 0.001; % LMS step size.
N= length(h);
DesiredSignal = filter(h,1,x)+ (Noise); % Desired signal at 10 times the Full scale Noise
[h,y] = mylms(x,DesiredSignal,delta,N,Fs,t);
subplot(5,1,4); plot(Fs*t(1:ShowLength),2*y(1:ShowLength)); grid on, title('Filtered Signal');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Function Code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [h, y] = mylms(x,d,delta,N,Fs,t)
M = length(x);
h = zeros(1,N);
for n=N:M
x1 = x(n:-1:n-N+1);
y(n) = h*x1';
e = d(n)-y(n);
h=h+delta*e*x1;
end

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

As the step size decreases, the ASE decreases.Original Clean Signal 150 100 F0 Full Scale Noise Signal 150 100 50 Original Signal Comupted with Full Scale Zero Mean Random

Add a comment
Know the answer?
Add Answer to:
LMS project Using the notes discussed in class: Implementing the LMS Algorithm First generate some signals clear all c...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT