OFDM Synchronization example in matlab

4 views (last 30 days)
greatestcon
greatestcon on 15 Apr 2015
I am reading the OFDM Synchronization example in Matlab and I have some questions in some codes.
In the OFDMReceiver.m file , function locatePreamble
How these length come?
windowLength = ceil(0.5*obj.FrameLength + length(obj.pPreamble));
rWin = x(1: windowLength-L+K-1);
PhatShort = Phat(ceil(length(Phat)/2):end-K/2+1);
if true
function preambleStartLocation = locatePreamble(obj, x)
% Locate the starting point of the preamble using cross correlation.
L = obj.FFTLength;
K = obj.FFTLength/4;
known = obj.pPreamble(1:K);
windowLength = ceil(0.5*obj.FrameLength + length(obj.pPreamble));
% Cross correlate
rWin = x(1: windowLength-L+K-1);
Phat = xcorr(rWin, conj(known));
Rhat = xcorr(abs(rWin).^2, ones(K,1)); % Moving average
% Remove leading and tail zeros overlaps
PhatShort = Phat(ceil(length(Phat)/2):end-K/2+1);
RhatShort = Rhat(ceil(length(Rhat)/2):end-K/2+1);
% Calculate timing metric
M = abs(PhatShort).^2 ./ RhatShort.^2;
% Determine start of short preamble. First find peak locations
MLocations = find(M > (max(M)*obj.PeakThreshold));
% Correct estimate to the start of preamble, not its center
MLocations = MLocations - (K/2+1);
% Determine correct peaks
peaks = zeros(size(MLocations));
desiredPeakLocations = (K:K:2*L)';
for i = 1:length(MLocations)
MLocationGuesses = MLocations(i) + desiredPeakLocations;
peaks(i) = length(intersect(MLocations(i:end), MLocationGuesses));
end
% Have at least obj.pNumRequiredPeaks peaks for positive match
peaks(peaks < obj.MinNumPeaksForMatch) = 0;
% Pick earliest peak in time
[numPeaks, frontPeakLocation] = max(peaks);
if ~isempty(peaks) && (numPeaks > 0)
preambleStartLocation = MLocations(frontPeakLocation);
else % No desirable location found
preambleStartLocation = -1;
end
% code
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!