%% Perform Zero-Forcing Equalization for RMC R.4
% Equalize the received signal for RMC R.4 after channel estimation. Use the zero forcing equalizer.
% Create cell-wide configuration structure and generate transmit signal. Configure propagation channel.

enb = lteRMCDL('R.4');                 
[txSignal,~,info] = lteRMCDLTool(enb,[1;0;0;1]);

chcfg.DelayProfile = 'EPA';
chcfg.NRxAnts = 1;
chcfg.DopplerFreq = 70;
chcfg.MIMOCorrelation = 'Low';
chcfg.SamplingRate = info.SamplingRate;
chcfg.Seed = 1;
chcfg.InitPhase = 'Random';
chcfg.InitTime = 0;         

txSignal = [txSignal; zeros(15,1)];
N = length(txSignal);
noise = 1e-3*complex(randn(N,chcfg.NRxAnts),randn(N,chcfg.NRxAnts));
rxSignal = lteFadingChannel(chcfg,txSignal)+noise;

%
% Perform synchronization and OFDM demodulation.

offset = lteDLFrameOffset(enb,rxSignal);
rxGrid = lteOFDMDemodulate(enb,rxSignal(1+offset:end,:));

%
% Create channel estimation configuration structure and perform channel estimation.

cec.FreqWindow = 9;
cec.TimeWindow = 9;
cec.InterpType = 'Cubic';
cec.PilotAverage = 'UserDefined';
cec.InterpWinSize = 3;
cec.InterpWindow = 'Causal';
hest = lteDLChannelEstimate(enb,cec,rxGrid);

%
% Equalize and plot received and equalized grids.

eqGrid = lteEqualizeZF(rxGrid,hest);

subplot(2,1,1);
surf(abs(rxGrid));
title('Received grid');
xlabel('OFDM symbol'); 
ylabel('Subcarrier');

subplot(2,1,2);
surf(abs(eqGrid));
title('Equalized grid');
xlabel('OFDM symbol'); 
ylabel('Subcarrier');

% Copyright 2012 The MathWorks, Inc.