In Matlab, I have a signal of 600 length seconds and applied the FFT (Fast Fourier Transform) to it in the 500 second, with No=1024 samples(4.096 seconds of data), in order to get the amplitude of the fundamental frequency (the mayor spike in the frequency domain). However, when comparing it with the amplitude value in the time domain, I note it has a much lower value. This is shown in the following graphs:
As can be seen, the amplitude in the frequency domain is almost one magnitude level below that of time domain. I have done the same test in other segments and signals but never getting the right or razonable values.
The principal segment code to generate the graph is the following:
%Substract the mean from the signal W, where W(su,1) is the time vector, and W(su,2) is the sampling vector.
Xo(su,1)=W(su,1);
Xo(su,2)=W(su,2)-mean(W(su,2));
% Window Time Duration(Seconds):
TT1=No/fm;
% Time instant(Seconds):
h=500;
%Time Instant at the end of the Window(Seconds):
Tf=h+TT1;
%Focused Signal Segment:
sub3=(h*250):((h+TT1)*250);
%Applying Hamming Windows to the Signal:
for g=h*250:(h+TT1)*250
w(g)=0.54-0.46*cos(2*pi*g/No);
Xo2(g,2)=Xo(g,2)*w(g);
end
%Getting Frequencies and the FFT of Xo2:
[freqP, xdftP, psdxP] = Mide_FFT_PSD(Xo2(sub3,1:2),fm);
%Plotting the Results:
po={'blue' , 'red' , 'green' , 'yellow'};
%Plot 1:
plot(W(:,1),W(:,2))
LineHandle1=plot(allAxesInFigure(1),[h h],get(gca,'YLim'),'Color','red','LineStyle',':');
LineHandle2=plot(allAxesInFigure(1),[Tf Tf],get(gca,'YLim'),'Color','red','LineStyle',':');
xlabel('Time (s)'); ylabel('Amplitude (g)'); title('Electromyogram of insect pump');
grid on
%Plot 2:
plot(freqP,xdftP,'Color',po{2})
xlabel('Frequency (Hz)'); ylabel('Amplitude (g)'); title('Amplitudes from FFT Window');
grid on;
where Mide_FFT_PSD.m does the following:
function [freq, xdft, psdx, phase] = Mide_FFT_PSD(datalist,fActual)
%Compute FFT & PSD
Fs = fActual;
x = datalist(:,2);
% x = datalist(:,1);
N = length(x);
freq = 0:Fs/length(x):Fs/2;
xdft = fft(x);
xdft = xdft(1:floor(N/2)+1);
psdx = (1/(Fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
psdx = psdx';
xdft = 1/length(x).*xdft;
xdft(2:end-1) = 2*xdft(2:end-1);
xdft = xdft';
phase = unwrap(angle(xdft));
xdft = abs(xdft);
end
I would like to know if I'm doing something wrong or if it's impossible to get the amplitude values from the FFT when the signal is not a pure sine wave. I have read that only energies are the same in both domains but not the amplitudes. However, I haven't found any rigurous information to confirm that yet.