I have written some other code to calculate both the energy and amplitude factors and ratio. See here:
% 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
If I change ECF to ACF at the apply correction factor, it corrects the amplitude factor. If I change the window to any window, like blackman or flattopwin, the ratio of either the energy or the amplitude is approximately 1, as it should. With the ACF applied, both peaks are the same value for normal FFT plot and windowed FFT plot, as it should.
But still, for the flattopwin, ECF = 2.3891 and ACF = 4.6391, which is not the same as in the table. Same for blackman: ECF and ACF does not match.
Do I calculate both the ECF and ACF right this way?