📄 frequency_estimation.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -