0
votes

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:

Red lines delimitates the signal segment where FFT where applied.

|FFT| vs Frequency. The sampling frequency is fm=250 Hz.

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.

1
If you look at the integral/sum expressions for the FT/DFT, you will see that the energies (normalized integral/sum of squares) are the same.Mad Physicist
And yes, peak amplitudes won't match at all in the general case. Your zeroth frequency in the DFT will be the mean of the data though.Mad Physicist
@MadPhysicist Thank you! I understand that I can get accurately the total energy of the signal but not the associated with the fundamental frequency or individual ones. Do you know what's the reason behind it? I have read about the finite length of the signal and the false distribution of part of the energy of one frequency to the ones in proximity. However, I don't know if there is a better way to explain it.Hecsalms
You are getting the energy associated with the individual frequencies. That's just the square of each bin.Mad Physicist

1 Answers

1
votes

The visual amplitude of a waveform in the time domain can consist of constructive interference from multiple spectral peaks in the frequency domain. This interference can be constructive or destructive depending on the relative phases. So the amplitude of a (looks periodic) time domain waveform can't always be determined by just looking the magnitude spectrum in the frequency domain.