% Adaptive filter using Basic Affine Projection Algorithm and
%
clear all;
close all;
clc;
L = 5000; %input data size
N = 40; %filter length
w0 = zeros(N,1); %initialization for adaptive filters
mu1 = 0.05; %step-size parameter
mu2 = 0.2;
mu3 = 1;
mu_max = 1; %the maximum value of the step-size parameter
SNR_dB = 30; %SNR
epsilon = 1e-4; %regularization parameter
MCruns = 100; %Monte Carlo simulation runs
C1 = 1e-5;
C2 = 1e-4;
C3 = 1e-6;
h = [0.1, -0.2, -0.3, 0.4, 0.4, -0.2, -0.1];
W = [ones(1,20), 0, -ones(1,19)];
mse_apa = zeros(L,1); % MSE vectors for Monte Carlo simulations
mse_apa1 = zeros(L,1);
mse_apa2 = zeros(L,1);
mse_vssapa = zeros(L,1);
mse_vssapa1 = zeros(L,1);
mse_vssapa2 = zeros(L,1);
msd_apa = zeros(1,L); % MSD vectors for Monte Carlo simulations
msd_apa1 = zeros(1,L);
msd_apa2 = zeros(1,L);
msd_vssapa = zeros(1,L);
msd_vssapa1 = zeros(1,L);
msd_vssapa2 = zeros(1,L);
for I = 1:MCruns
x = filter(h,1,randn(L,1)); %input data
y = filter(W,1,x) ; %desired response
ey2=mean(y.^2);
sgma=sqrt(ey2*1e-3); %SNR=30dB
gama=sqrt(5)*sgma;
vk=sgma*randn(1,L);
d=y+vk; %
I
%
% Full-update APA
%
P = 4; %APA order
[eAPA,w] = full_apa(x,d,N,P,w0,mu1,epsilon); %mu = 0.05
mse_apa = mse_apa + eAPA.^2;
w_opt = W;
for ii = 1:L
msd_apa(1,ii) = msd_apa(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
[eAPA1,w] = full_apa(x,d,N,P,w0,mu2,epsilon); %mu = 0.2
mse_apa1 = mse_apa1 + eAPA1.^2;
for ii = 1:L
msd_apa1(1,ii) = msd_apa1(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
[eAPA2,w] = full_apa(x,d,N,P,w0,mu3,epsilon); %mu = 1
mse_apa2 = mse_apa2 + eAPA2.^2;
for ii = 1:L
msd_apa2(1,ii) = msd_apa2(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
%
% VSS-APA
%
P = 4; %APA order
[eVSSAPA,w] = vss_apa(x,d,N,P,w0,mu_max,epsilon,C1);%C1=2e-5
mse_vssapa = mse_vssapa + eVSSAPA.^2;
for ii = 1:L
msd_vssapa(1,ii) = msd_vssapa(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
[eVSSAPA1,w] = vss_apa(x,d,N,P,w0,mu_max,epsilon,C2);%C2=2e-4
mse_vssapa1 = mse_vssapa1 + eVSSAPA1.^2;
for ii = 1:L
msd_vssapa1(1,ii) = msd_vssapa1(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
[eVSSAPA2,w] = vss_apa(x,d,N,P,w0,mu_max,epsilon,C3);%C3=2e-6
mse_vssapa2 = mse_vssapa2 + eVSSAPA2.^2;
for ii = 1:L
msd_vssapa2(1,ii) = msd_vssapa2(1,ii) + norm(w(ii,:)-w_opt)/norm(w_opt);
end
end
mse_apa = mse_apa/MCruns;
mse_apa1 = mse_apa1/MCruns;
mse_apa2 = mse_apa2/MCruns;
mse_vssapa = mse_vssapa/MCruns;
mse_vssapa1 = mse_vssapa1/MCruns;
mse_vssapa2 = mse_vssapa2/MCruns;
msd_apa = msd_apa/MCruns;
msd_apa1 = msd_apa1/MCruns;
msd_apa2 = msd_apa2/MCruns;
msd_vssapa = msd_vssapa/MCruns;
msd_vssapa1 = msd_vssapa1/MCruns;
msd_vssapa2 = msd_vssapa2/MCruns;
%%
% MSE plot
figure(1)
plot(1:L,db(mse_apa/max(mse_apa)),'k-',...
1:L,db(mse_apa1/max(mse_apa1)),'b:',...
1:L,db(mse_apa2/max(mse_apa2)),'r-.',...
1:L,db(mse_vssapa/max(mse_vssapa)),'g-',...
1:L,db(mse_vssapa1/max(mse_vssapa1)),'c-.',...
1:L,db(mse_vssapa2/max(mse_vssapa2)),'m--');
xlabel('Number of iterationsa');
ylabel('MSE(dB)');
grid on;
legend('standard APA(\mu=0.05)','standard APA(\mu=0.2)','standard APA(\mu=1)','VSS APA(C=1e-5)','VSS APA(C=1e-4)','VSS APA(C=1e-6)');
% MSD plot
figure(2)
plot(1:L,db(msd_apa/max(msd_apa)),'k-',...
1:L,db(msd_apa1/max(msd_apa1)),'b:',...
1:L,db(msd_apa2/max(msd_apa2)),'r-.',...
1:L,db(msd_vssapa/max(msd_vssapa)),'g-',...
1:L,db(msd_vssapa1/max(msd_vssapa1)),'c-.',...
1:L,db(msd_vssapa2/max(msd_vssapa2)),'m--');
xlabel('Number of iterations ');
ylabel('MSD(dB)');
grid on;
legend('standard APA(\mu=0.05)','standard APA(\mu=0.2)','standard APA(\mu=1)','VSS APA(C=1e-5)','VSS APA(C=1e-4)','VSS APA(C=1e-6)');
评论7