% This Matlab script file compares the MSE performance, under ideal feedback, 
% for a normal mode DFE, time-reversal mode DFE and an LC-BiDFE

C1=[0.2 1 0.3162 -0.2 0.1 -0.05 0.02]; %Sample asymmetric channel
C2=[0.3162 1 0.3162]; %sample symmetric channel

C=C1; 
C=C/sqrt(C*C'); %Normalize the channel

Lf1=4;Lb1=3;
Lf2=4;Lb2=3;

MSE_conv=[];MSE_tr=[];MSE_div=[];

for snr=0:20,

lambda=10^(-snr/10);
[f1,b1,delay1,mmse]=dfe_tap_estimator(C,Lf1,Lb1,lambda,1,0);
MSE_conv=[MSE_conv mmse];
[f2,b2,delay2,mmse]=dfe_tap_estimator(fliplr(C),Lf2,Lb2,lambda,1,0);
MSE_tr=[MSE_tr mmse];
[mmse,rho,alpha]=trdfe_mse(C,f1,b1,delay1,f2,b2,delay2,lambda);
MSE_div=[MSE_div mmse];

end;

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







