% This Matlab script compares the MSE performance, under ideal feedback
% assumption, of a "single-length" LC-BiDFE with a "double-length" normal
% mode DFE and a time-reversal mode DFE. 

C1=[0.2 1 0.3162 -0.2 0.1 -0.05 0.02]; 
C=C1;
C=C/sqrt(C*C'); % Normalize the channel

MSE_conv=[];MSE_tr=[];MSE_div=[];
snr=15;
lambda=10^(-snr/10);

for L=1:1:10,

MSE_temp=[];
for Lf=1:L,
[f1,b1,delay1,mmse]=dfe_tap_estimator(C,Lf,L-Lf,lambda,1,0);
[f2,b2,delay2,mmse]=dfe_tap_estimator(fliplr(C),Lf,L-Lf,lambda,1,0);
[mmse,rho,alpha]=trdfe_mse(C,f1,b1,delay1,f2,b2,delay2,lambda);
MSE_temp=[MSE_temp mmse];
end;

MSE_div=[MSE_div min(MSE_temp)];
MSE_temp=[];

for Lf=1:2*L,
[f1,b1,delay1,mmse]=dfe_tap_estimator(C,Lf,2*L-Lf,lambda,1,0);
MSE_temp=[MSE_temp mmse];
end;

MSE_conv=[MSE_conv min(MSE_temp)];
MSE_temp=[];

for Lf=1:2*L,
[f2,b2,delay2,mmse]=dfe_tap_estimator(fliplr(C),Lf,2*L-Lf,lambda,1,0);
MSE_temp=[MSE_temp mmse];
end;

MSE_tr=[MSE_tr min(MSE_temp)];
MSE_temp=[];

end;

L=1:1:10;
set(0,'DefaultAxesFontSize',18);
set(0,'DefaultTextFontSize',18);
set(0,'DefaultTextFontName','times');
set(0,'DefaultAxesFontName','times');
figure;
pl1=plot(2*L,10*log10(MSE_conv),'b-^','LineWidth',2);
hold on;
pl2=plot(2*L,10*log10(MSE_tr),'r-*','LineWidth',2);
pl3=plot(2*L,10*log10(MSE_div),'k-o','LineWidth',2);
grid on;
legend([pl1,pl2,pl3],'Normal Mode DFE','Time-Reversal Mode DFE','LC-BiDFE');
xlabel('Number of Taps','FontSize',18);
ylabel('MSE  in  dB','FontSize',18);







