Rife插值测频

近日整理发现了部分几年前写的代码,差点忘了写过它们。现在贴在这里,说不定哪天还能用一用。

clc;clear all;close all;

show_figure_A = 1;
show_figure_B = 1;

f = 905;
fs = 3000;
N = 128;
t = (0:N-1)/fs;
s = cos(2*pi*f*t);
%% 时域加窗
w = hanning(128)';
ss = s.*w;
y = abs(fft(ss,128));
if show_figure_A == 1 
    figure;
    plot(y,'o');
    title('时域加窗频谱');
    figure;
    plot(s,'r');
    hold on;
    plot(ss,'b');
    hold off;
    title('时域加窗前后信号');
end
%% 频域加窗
y2 = abs(fft(s,128));
y2 = [0 y2 0];
yy = [];
for i = 1:128
    yy(1,i) = y2(1,i+1)/2 + y2(1,i)/4 + y2(1,i+2)/4;
end
yy = abs(yy);
if show_figure_B == 1 
    figure;
    plot(yy,'o');
    title('频域加窗频谱');
end
%% Rife测频
k_index = 40;
kr_index = 39;
K = yy(1,k_index);
KR = yy(1,kr_index);
if kr_index>k_index
    kk = k_index-1+(2*KR-K)/(KR+K);
else
    kk = k_index-1-(2*KR-K)/(KR+K);
end
f = kk/128*fs;
fprintf('Rife插值后频率为 %f \n',f);

Rife插值测频_第1张图片

你可能感兴趣的:(雷达_对抗,信号处理)