我想在信号窗口上找到瞬时频率。我正在提取一小部分信号并试图在该窗口中找到瞬时频率。但是该频率与信号的实际频率不匹配。下面是我的代码。
close all; clear all; clc
fs = 25000;
T = 0.5;
t = 0:1/fs:T;
n = length(t);
m = floor(n/4);
f1 = 100;
z1 = cos(2*pi*f1*t(1:m));
f1 = 200;
z2 = cos(2*pi*f1*t(1:m));
f1 = 300;
z3 = cos(2*pi*f1*t(1:m));
f1 = 400;
z4 = cos(2*pi*f1*t(1:(n-3*m)));
z = [z1 z2 z3 z4];
window = 100;
wStart = 1;
wEnd = wStart + window;
freqs = [];
while wEnd < length(z)
x = z(wStart:wEnd);
y = t(wStart:wEnd);
h=hilbert(x);
unrolled_phase = unwrap(angle(h));
dx = diff(unrolled_phase);
dy = diff(y);
p = dx./dy;
inst_freq = p/(2*pi) + 2*pi;
freqs = [freqs inst_freq];
wStart = wEnd;
wEnd = wStart + window;
end
'freqs' 的情节是这样的:
我认为我计算频率的方式有问题,但我不确定。有人可以帮忙吗?从代码中可以看出,我只需要将频率设为 100,200,300 和 400。我要做的就是找到每个频率的起点(时间)