Академический Документы
Профессиональный Документы
Культура Документы
ADAPTIVE FILTERS
SUBMITTED BY
ABDULLAH HASAN
SUBMITTED TO
DR. TAHIR ZAIDI
MS-83
pg. 0
Question
a) Generate a random signal. The signal should be labeled x[n] and should have 1000 samples.
b) Generate a 4 tap moving average filter.
c) Generate 4 taps cross correlation and auto correlation matrices.
d) Use the LMS equation to calculate the taps of the moving average filter for 3 different values
of µ.
e) Use the RLS equation to calculate the taps of the moving average filter using any appropriate
value for δ and λ.
MATLAB CODE
clc
close all
clear all
for s=1:M
un(s)=xn(s) % Input signal: taking 4 values of random signal
end
dn=mov_avg % Desired Signal: Moving average filter
length_matrix=length(un)+length(dn)-1; % finding the desired taps for
correaltion matrix
cross_cor=fftshift(ifft(fft(un,length_matrix).*conj(fft(dn,length_matr
ix))));
% cross correaltion matrix
auto_cor=fftshift(ifft(fft(un,length_matrix).*conj(fft(un,length_matri
x))));
% auto correaltion matrix
pg. 1
%Use the LMS equation to calculate the taps of the moving average
filter
%for three different values of µ.%
% Use the RLS equation to calculate the taps of the moving average
filter using any appropriate value for ? and ?.
pg. 2
t=[0:3]; % defining x-axis for graphs
w=zeros(1,M); % Initializing taps (w) of the filter
ita=10^4;
I=ones(1,M); %Identity Matrix
P=ita*I; %inverse correaltion matrix
for i=1:4
yn(i) = w(i)' * un(i);
en(i) = dn(i) - yn(i); %a priori estimation error
pi_n(i) = P(i) * un(i);
q = un(i)' * pi_n(i);
v = 1/(1+q);
kn(i) = v * pi_n(i); %Gain Vector
w(i+1) = w(i) + en(i)*kn(i) %tap weights
P(i+1) = P(i) - kn(i)*pi_n(i); %inverse correlation matrix
end
for i=1:4
yd(i) = sum(w(i)' * un(i)) %Adaptive Output
end
figure;
plot(t,dn)
title('Desired Signal (RLS)')
figure;
plot(t,un)
title('Input Signal (RLS)')
figure;
plot(t,en)
title('Error (RLS)')
figure;
plot(t,yd)
title('Adaptive Desired output (RLS)')
pg. 3
GRAPH PLOTS
pg. 4
pg. 5
pg. 6
pg. 7
pg. 8
OUTPUT
un =
3 3 1 3
dn =
2.5000 2.2500 1.7500 1.7500
Rxx =
9.0000 12.0000 15.0000 28.0000
12.0000 9.0000 12.0000 15.0000
15.0000 12.0000 9.0000 12.0000
28.0000 15.0000 12.0000 9.0000
eigen_matrix =
-19.5440
-2.4560
0.8397
57.1603
lamda_max =
-2.4560
lamda_max =
0.8397
lamda_max =
57.1603
upper_limit_mu =
0.0350
mu =
0.0221
en =
2.5000 1.7531 1.4682 0.8074
pg. 9
w=
0 0.1656 0.2818 0.3142 0.3677
yn =
0 0.4969 0.2818 0.9426
mu =
0.0124
en =
2.5000 1.9705 1.5834 1.1911
w=
0 0.0932 0.1666 0.1863 0.2307
yn =
0 0.2795 0.1666 0.5589
mu =
0.0349
en =
2.5000 1.4651 1.3350 0.3654
w=
0 0.2616 0.4150 0.4615 0.4998
yn =
0 0.7849 0.4150 1.3846
w=
0 0.8333 0.7917 0.8421 0.7589
yd =
0 2.5000 0.7917 2.5263
pg. 10