%*********************************************************************************
% LMS ADAPTIVE TRANSVERSAL FILTER EQUALIZER
%
%
%
% This is MATLAB code for a variable order LMS Adaptive
% Transversal Filter Equalizer. The model includes:
%
% (1) Variable length (seqlen) Pseudorandom symbol generator with
% binary-to-real symbol conversion
% (2) Variable-order Transversal filter channel model
% synthesized via shift register ak and channel
% coefficient vector pk
% (3) Additive gaussian noise component z1 with S/N
% compensation (SNR)
% (4) Variable-order Transversal filter equalizer model
% synthesized via shift register rk and equalizer
% coefficient vector ck
% (5) Output symbol delay compensation (delay1:channel,
% delay2:equalizer)
% (6) Ensemble averaging option,M (limits iteration size)
%
% This code was generated using the student edition of MATLAB version 4
% and therefore the number of iterations was limited due primarily
% to storage vector size limitations. But the number of availble iterations
% appears sufficient to model the characterized channel and equalizer
% The following plots are generated:
%
% (1) plot of channel input vs. channel output
% (2) plot of channel input vs. equalizer output
% (3) plot of mean squared error (ensemble averaged)
% (4) plot showing the evolution of equalizer coefficients
%*********************************************************************************
clear
seqlen=500; % length of ensemble sequence
M=10; % number of ensembles (2 to 32)
pk=[0.25,1,0.3]; % channel coefficient vector (ISI)
SNR=500; % symbol to noise ratio desired (5,50,120)
comments='pk=[0.25,1,0.3], High SNR';
%---------------------------------------------------------------------------------
% SYMBOL SEQUENCE GENERATOR
SR=ones(size(1:14));
SR(9)=0;
Xn=zeros(size(1:seqlen));
Ak=zeros(size(1:seqlen));
for n=1:seqlen
Xn(n)=xor(SR(14),xor(SR(13),xor(SR(9),SR(11))));
SR(2:14)=SR(1:13);
SR(1)=Xn(n);
if Xn(n)==0
Ak(n)=-1;
else
Ak(n)=1;
end
end
%---------------------------------------------------------------------------------
% INITIALIZATION
ak=zeros(size(1:length(pk))); % channel shift register
ak=ak-1;
ck=[1,0,1,1,0,0,1,0,0]; % equalizer coefficient vector (initial)
rk=zeros(size(1:length(ck))); % equalizer shift register
rk=rk-1;
delay1=round(length(ak)/2)-1; % channel delay
delay2=round(length(rk)/2)-1; % equalizer delay
R2=zeros(size(length(seqlen)));
Q2=zeros(size(length(seqlen)));
%---------------------------------------------------------------------------------
% LMS MODEL
for m=1:M
m
for k=1:seqlen
A=Ak(k); % retrieve symbol
ak(2:length(ak))=ak(1:length(ak)-1);
ak(1)=A; % shift symbol into channel register
r1=conv(ak,pk); % convolve data with channel model
r2=r1(round(length(r1)/2)); % correlate channel delay
z1=exp(-SNR/20)*randn(1); % compute random noise sample at proper SNR
r3=r2+z1; % add noise to channel output
R2(k)=r3; % composite channel output
R=r3;
if k>delay1
past=k-delay1;
ER(k)=Ak(past)-r2; % calculate channel error
end
rk(2:length(rk))=rk(1:length(rk)-1);
rk(1)=R; % shift channel output into equalizer register
q1=conv(rk,ck); % convolve with equalizer model
q2=q1(round(length(q1)/2)); % correlate equalizer delay
if q2<0 % slicer
q3=-1;
else
q3=1;
end
Q2(k)=q2; % equalizer output estimate
if k>(delay1+delay2) % calculate delay compensated mean-squared-error
past2=k-(delay1+delay2);
EQ(k)=Ak(past2)-q2;
Q3(k)=Ak(past2)-q3;
MSE(k)=EQ(k)^2;
Q4(k)=mean(abs(Q3(k)^2));
CC(k,:)=ck;
egn=eig(rk.'*rk); % compute gradient, stepsize, and new equalizer
emax=max(egn); % coefficient vector
beta=2/(10*emax);
cnxt=((eye(length(rk))-beta*rk.'*rk)*ck.')'+beta*Ak(past2)*rk;
chng=abs(cnxt-ck);
ck=cnxt; % update equalizer coefficient vector
end
end
MSEE(m,:)=MSE;
end
MSEEE=mean(MSEE);
% PLOTS
figure;
subplot(1,2,1);
orient landscape;
plot(R2,Ak);
grid on;
axis([-10,10,-2,2]);
xlabel('Channel Output');
ylabel('Channel Input');
title('Channel Input vs. Channel Output');
gtext(comments);
subplot(1,2,2);
orient landscape;
plot(Q2,Ak);
grid on;
axis([-10,10,-2,2]);
xlabel('Equalizer Output');
ylabel('Channel Input');
title('Channel Input vs. Equalizer Output');
figure;
orient landscape;
plot(MSEEE);
grid on;
axis auto;
xlabel('Iteration Index');
ylabel('Mean Squared Error');
title('Mean Squared Error vs. Iteration');
gtext(comments);
figure;
orient landscape;
plot(CC);
grid on;
xlabel('Iteration Index');
ylabel('Equalizer Coefficient Values');
title('Evolution of Equalizer Coefficients');
gtext(comments);