sfd_detection.m

来自「source Matlab traites the UWB」· M 代码 · 共 43 行

M
43
字号
function [sfd_index] = sfd_detection(rx_down,sfd_code,sfd_thld, ...    fine_sync_index,channel_mask,G,CODE_ID,blocks_per_code_symbol,PLOT_DEBUG)code_len = length(len31_preamble_code(CODE_ID));samples_per_code = code_len * blocks_per_code_symbol;%integrate over 31*16 samples ie one whole code. at the same time also%apply the channel mask and the code.rx_sfd_zero = zero_pad_reshape(rx_down(fine_sync_index+ ...    G*samples_per_code:end),samples_per_code);if(isempty(rx_sfd_zero))  sfd_index = 0;else  rx_sfd_weighted = reshape(rx_sfd_zero,blocks_per_code_symbol, ...    length(rx_sfd_zero)/blocks_per_code_symbol)'*channel_mask;  rx_sfd_int = abs(len31_preamble_code(CODE_ID))* ...    (reshape(rx_sfd_weighted,code_len,length(rx_sfd_weighted)/code_len));  %create sfd_template  sfd_templ = 2*abs(sfd_code)-1;   sfd_corr = conv(rx_sfd_int,fliplr(sfd_templ));%   if(PLOT_DEBUG)%       figure%       plot(sfd_corr(length(sfd_templ):end))%       hold on%       plot(sfd_thld * ones(1,length(sfd_corr)),'m')%   end  %find the first value in the correlation above the threshold  sfd_ind_corr = find(sfd_corr(length(sfd_templ):end-(length(sfd_templ)-1))>=sfd_thld);  if(isempty(sfd_ind_corr))      sfd_index = 0;  else      sfd_index = samples_per_code*(sfd_ind_corr(1) - 1) + fine_sync_index+ ...          G*samples_per_code;  endendreturn;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?