frequency_estimation.m

来自「mimo2x2天线选择系统的全系统matlab程序,先前的是dsp程序.」· M 代码 · 共 32 行

M
32
字号
function Fc_hat = frequency_estimation(pilot_seq,Fs)
% counting the zero-crossing points number and decide the frequency
% pilot_seq reference signal for counting zero-crossing points
% Fs sampling frequency

data_len = length(pilot_seq);
% find the sign of the sequence
s_sign = sign(pilot_seq);
% subtract the previous value from the next, non-zero means zero-crossing
zero_cross = ((s_sign(2:end)-s_sign(1:end-1))~=0);
% find the first and last zero_cross points
T_start = 0;
T_end = 0;
for i = 1:data_len-1
    if zero_cross(i)~=0
        if T_start == 0
            T_start = i;
        else
            T_end = i;
        end
    end
end

% count the number of zero-crossing points
N_cross = sum(zero_cross(T_start:T_end));
% find accuate instance of zero-crossing by inserting method
T_start = T_start-1+abs(pilot_seq(T_start-1)/(pilot_seq(T_start-1)-pilot_seq(T_start)));
T_end = T_end-1+abs(pilot_seq(T_end-1)/(pilot_seq(T_end-1)-pilot_seq(T_end)));
% time duration of the selected sinusoid sequence
T_sin = (T_end-T_start+1)/Fs; 
% there are two zero-crossing points in each period. thus divided by 2
Fc_hat = (N_cross-1)/(2*T_sin);

⌨️ 快捷键说明

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