clear
echo on

% Plot waterfall curves (SER vs. SNR) for M-QAM over complex
% T/2-spaced microwave channels with AWGN equalized by a
% Unbiased MMSE-FSE+DFE receiver (i.e. MMSE receiver scaled to
% set cursor to unity) 

% Load channel
load /home/combine/raulc/research/sims/comms/channels/chan3.mat
C=C/norm(C);

% Select FSE and DFE lengths
Nf=96;
Nd=32;
symbol='x'; 

% Select cursor as position of 
% maximum tap of channel
% (NOTE: this is not the optimum delay choice, 
%  but it is fairly good and saves time.)
[Y,delta1]=max(C);

% Add nT delay for decision feedback
% to channel-FSE combination delay
n=2;
n=0;
delta2=(delta1+1)+n;

% Define set of SNR (dB) to calculate SER
snrdb=[5:2:30];
%snrdb=35;

% Set M-QAM constellation size
M=64;

for k=1:length(snrdb), 

   % Normalize channel for unit received power 
   snr=10^(snrdb(k)/10);
   desirednorm=2*(1-1/snr);
   h=C*sqrt(desirednorm); 


   % Find UMMSE-FSE+DFE design 
   [f,d,ummse]=ummse_fse_dfe(h,snrdb(k),Nf,Nd,delta1,delta2);

   ser(k)=qam_ser(M,ummse); 

end;

semilogy(snrdb,ser,'-',snrdb,ser,symbol);
xlabel('SNR (dB)');
ylabel('SER');
title(['SER vs. SNR for ' num2str(M) '-QAM for channel #3']);


echo off
