在我的信号上使用窗口时,我想使用校正因子来校正窗口的能量或振幅。
我已经写了一些其他代码来计算能量和幅度因子和比率。见这里:
% signal
dt = 0.001;
fs = 1/dt;
x = 0:dt:10;
N = length(x);
y = 3*sin(2*pi*x*52) + 5.2*sin(2*pi*x*53) + 14*randn(size(x));
figure(1)
subplot(3,1,1)
plot(x,y)
title('signal')
rms_y = rms(y);
% window
w = hanning(N); w = w';
rms_w = rms(w);
mean_w = mean(w);
ECF = 1/rms_w; % Energy correctionfactor
ACF = 1/mean_w; % Amplitude correctionfactor
% windowed signal
ws = (w.*y);
rms_ws = rms(ws);
% fft signal
Z = 100*N; % add zeros
f = fs*(0:Z/2)/Z;
Yfft = fft(y,Z);
Y2 = abs(Yfft)/N;
Y = Y2(1:Z/2+1);
Y(2:end-1) = 2*Y(2:end-1);
figure(1)
subplot(3,1,2)
plot(f,Y)
title('signal frequency spectrum')
xlim([48 57]);
rms_Y = rms(Y);
% fft windowed signal
Yfftws = fft(ws,Z);
Y6 = abs(Yfftws)/N;
Y6 = ECF*Y6; % apply correctionfactor
Y5 = Y6(1:Z/2+1);
Y5(2:end-1) = 2*Y5(2:end-1);
figure(1)
subplot(3,1,3)
plot(f,Y5)
title('windowed frequency spectrum with correction factor')
xlim([48 57]);
rms_Yws = rms(Y5);
amplitude_Y = max(Y);
amplitude_Y_windowed = max(Y5);
ratio_amplitude = amplitude_Y/amplitude_Y_windowed
ratio_energy = rms_Y/rms_Yws
如果我在%应用修正系数处将ECF更改为ACF,则会更正幅度系数。如果我将窗口更改为任何窗口,如blackman或flattopwin,则能量或幅度的比率大约为1,应该如此。应用ACF后,两个峰值均为约。正常FFT图和窗口FFT图的相同值,应该是这样。
但是,正如本网站https://community.plm.automation.siemens.com/t5/Testing-Knowledge-Base/Window-Correction-Factors/ta-p/431775表中所述,对于flattopwin ECF = 2.26和ACF = 4.18。根据我的脚本计算,flattopwin的因子是ECF = 2.3891和ACF = 4.6391,这与表中的不同。使用blackman也是如此:ECF和ACF不匹配。因此,对于使用汉明和汉宁来说,这些值是正确的。
我是否同时计算ECF和ACF?