?? rx_frequency_sync.m
字號:
% Frequency error estimation and correction
function [out_signal, freq_est] = rx_frequency_sync(rxsignal, sim_options)
global sim_consts;
[n_tx_antennas, n_rx_antennas] = get_n_antennas(sim_options);
% Estimate the frequency error
if sim_options.FreqSync
% allows for error in packet detection
pkt_det_offset = 30;
% averaging length
rlen = 128;
% short training symbol periodicity
D = 16;
phase = rxsignal(:,pkt_det_offset:pkt_det_offset+rlen-D).* ...
conj(rxsignal(:,pkt_det_offset+D:pkt_det_offset+rlen));
% add all estimates
phase = sum(phase, 2);
% with rx diversity combine antennas
phase = sum(phase, 1);
freq_est = -angle(phase) / (2*D*pi/sim_consts.SampFreq);
radians_per_sample = 2*pi*freq_est/sim_consts.SampFreq;
else
% Magic number
freq_est = -sim_options.FreqError;
radians_per_sample = 2*pi*freq_est/sim_consts.SampFreq;
end
% Now create a signal that has the frequency offset in the other direction
siglen=length(rxsignal(1,:));
time_base=0:siglen-1;
correction_signal=repmat(exp(-j*(radians_per_sample)*time_base),n_rx_antennas,1);
% And finally apply correction on the signal
out_signal = rxsignal.*correction_signal;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -