sym_timing.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:2k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- function [timed_sym , err_sym_timing] = sym_timing( coarse_freq_out ,N_subc, PrefixRatio, N_sym ,...
- N_syn_preamble,syn_preamble,Window2,TimingAhead, N_Rx_ant,Timing,AddChFreq)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 和已知的序列求相关, 得到符号定时位置
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if ~AddChFreq
- N_sample_ofdm = N_subc*(1+PrefixRatio);
- if Timing
- % 得到第2个OFDM符号的时域样点值
- training_timing = syn_preamble( 1 ,N_sample_ofdm + 1 : N_sample_ofdm + Window2 );
- for ant = 1: N_Rx_ant
- recv_tmp = coarse_freq_out(:,:,ant);
- % 搜索第二个OFDM符号, 开始搜索的位置是N_sample_ofdm*3/4, 结束搜索的位置N_sample_ofdm*5/4
- cnt = 1;
- start_sample = N_sample_ofdm*3/4;
- end_sample = N_sample_ofdm*5/4;
- for start_idx = start_sample:end_sample
- correlation(cnt) = sum( (recv_tmp(start_idx : start_idx + Window2 - 1).*conj(training_timing)) );
- cnt = cnt + 1;
- end
- %[max_value, max_idx] = max(correlation);
- m_idx = find(abs(correlation) > 0.5*max(abs(correlation)));
- max_idx = m_idx(1);
- % plot(abs(correlation));
- timing_idx = max_idx + start_sample - 1; % 最佳定时值: N_sample_ofdm + 1
- idx_cnt(ant) = timing_idx - TimingAhead;
- end
- % 计算得到多条天线的加权定时位置
- idx = sum(idx_cnt)/N_Rx_ant;
- % 定时截取
- timed_sym = coarse_freq_out( 1, idx + N_sample_ofdm*(N_syn_preamble-1) : idx + N_sample_ofdm*(N_sym-1) - 1, :);
- % 计算定时误差的样点数
- err_sym_timing = (N_sample_ofdm + 1) - idx ;
- else
- timed_sym = coarse_freq_out( 1, N_sample_ofdm*N_syn_preamble + 1 : N_sample_ofdm*N_sym , :);
- err_sym_timing = 0;
- end
- else
- timed_sym = NaN;
- err_sym_timing = NaN;
- end