fine_sync_block.m

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

M
44
字号
function [fine_sync_index] = fine_sync(rx_down,corr_template,thld,...                blocks_per_code_symbol,code_len,coarse_sync_index,PLOT_DEBUG);         %from -block to + 2blocks    corr3 = conv(rx_down, fliplr(corr_template));    corr3 = corr3(length(corr_template):length(corr_template)+blocks_per_code_symbol*4);    %[max_corr4, ind_corr4] = max(corr3(blocks_per_code_symbol:2*blocks_per_code_symbol));        %the max cannot be in last part    [max_corr4, ind_corr4] = max(corr3(1:end-blocks_per_code_symbol));        %ind_corr4 = ind_corr4 + blocks_per_code_symbol - 1;        %we now go backwards through the correlation until we find one sample    %that is not above the threshold, the max number of steps we go back is    %blocks_per_code_symbol/2    current_index = ind_corr4;    t0_index = ind_corr4;    for i=1:floor(blocks_per_code_symbol/2)        current_index = current_index - 1;        %wrap around if it goes over the beginning        if(current_index == 0)            break;        end        if(corr3(current_index) >= thld && corr3(current_index)>corr3(current_index+blocks_per_code_symbol))            t0_index = current_index;        end    end    fine_sync_index = coarse_sync_index - blocks_per_code_symbol + t0_index - 1;    %     if(PLOT_DEBUG)%         figure%         plot(corr3)%         hold on%         plot(thld*ones(1,length(corr3)),'m')%         line([t0_index t0_index],[0 max(corr3)],'Color','g')%         line([ind_corr4 ind_corr4],[0 max(corr3)],'Color','y')%     endreturn;

⌨️ 快捷键说明

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