%% Estimate Frequency Offset
% Perform frequency offset estimation and correction on an uplink signal, to which a frequency offset has been applied.
% Generate uplink RMC A3-2.

[txWaveform,rgrid,cfg] = lteRMCULTool('A3-2',[1;0;0;1],'Fdd',2);

%
% Apply an arbitrary frequency offset of 51.2 Hz.

t = (0:length(txWaveform)-1).'/cfg.SamplingRate;
txWaveform = txWaveform .* exp(1i*2*pi*51.2*t);

%
% Estimate and display the frequency offset.

offset = lteFrequencyOffset(cfg,txWaveform);
disp(['Frequency offset: ' num2str(offset) ' Hz'])

%
% Correct for frequency offset.

rxWaveform = lteFrequencyCorrect(cfg,txWaveform,offset);

%
% Perform SC-FDMA demodulation.

rxGrid = lteSCFDMADemodulate(cfg,rxWaveform);

% Copyright 2012 The MathWorks, Inc.