?? rx_fine_time_sync.m
字號:
function fine_time_est = rx_fine_time_sync(input_signal, sim_options)
%符號定時算法
global sim_consts;
[n_tx_antennas, n_rx_antennas] = get_n_antennas(sim_options);%獲取分集天線數量
if sim_options.FineTimeSync
%timing search window size,定時搜索窗口長度
start_search=130;
end_search=200;
% get time domain long training symbols,獲得時域長訓練符號
long_tr_symbols = tx_freqd_to_timed(sim_consts.LongTrainingSymbols);%以sim_consts.LongTrainingSymbols為輸入參數調用函數tx_freqd_to_timed
% 'LongTrainingSymbols', [1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 ...
% 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 1], ...
if sim_options.UseTxDiv %是否使用發射分集,若使用,則執行
long_trs = [long_tr_symbols(49:64) long_tr_symbols(1:48)];%???????
else %沒使用,則執行
long_trs = [long_tr_symbols(33:64) long_tr_symbols(1:32)];%?????
end
time_corr_long = zeros(n_rx_antennas,end_search-start_search+1);%zeros(接收天線數量,200-130+1)
for k=1:n_rx_antennas
% calculate cross correlation ,計算互相關
for idx=start_search:end_search %130:200
time_corr_long(k,idx-start_search+1) = sum((input_signal(k,idx:idx+63).*conj(long_trs)));%從信號的第130列開始計算p39的式子,到第200列結束計算,每次循環計算的窗口長度L為64,搜索長度為71.
end
end
% combine, if we had two antennas
time_corr_long = sum(abs(time_corr_long),1);%取絕對值后,按列相加,得行向量
%figure(3);
%plot(time_corr_long)
%grid on
[max_peak_long,long_search_idx] = max(abs(time_corr_long));%將行向量中的最大值賦予max_peak_long,其索引賦予long_search_idx
if sim_options.UseTxDiv
fine_time_est = start_search-1 + long_search_idx+16;%定時時間計算,加上開始搜索的時間
else
fine_time_est = start_search-1 + long_search_idx+32;
end
else %如果沒有選中定時同步選項,則設置默認值
% Magic numbers
if ~sim_options.UseTxDiv
fine_time_est = 194;
else
fine_time_est = 194-16;
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -