0
$\begingroup$

Using MATLAB's fft function, I would like to retrieve the amplitude and frequency of this particular signal :

My data file (a) has 2 columns, first one for time ans the second for amplitude, I tried this script

    DT = (a(2,1)-a(1,1)); 
    Fs = 1/DT; % sampling frequency
    NFFT = 2^nextpow2(n);
    xdft = fft(a(:,2),NFFT)/n;
    f = Fs/2*linspace(0,1,NFFT/2+1);

    plot(f,2*abs(xdft(1:NFFT/2+1)))

The output is :

which is not corresponding to my amplitude. Thanks a lot for your help.

fft with all the harmonics :

$\endgroup$
  • $\begingroup$ Which value of amplitude do you expect? $\endgroup$ – AlexTP May 12 '17 at 13:20
  • $\begingroup$ Hay Alex, I expect 0.19 like in the figure 1, more precise 0.19168. $\endgroup$ – liquid-snake May 12 '17 at 13:31
2
$\begingroup$

The Fourier Transform will decompose your non-sinusoidal signal into harmonics, dominantly odd harmonics since your distortion appears symmetrical, and the amplitude as you derive would be the amplitude of the relevant sinusoidal harmonic (so in your case it looks like the fundamental is shown, so we are seeing the amplitude of the first fundamental harmonic which is a sinusoidal signal). It will be less than the peak amplitude shown in the time domain plot, which is the composite of all the harmonics.

Other factors that will effect the amplitude is spectral leakage due to your use of a rectangular window (so to the extent the harmonics fall into a sidelobe of the kernel for your rectangular window) and scalloping loss (to the extent the fundamental frequency is between an integer sub-multiple of your sampling frequency. Both of these effects are described in more detail in my favorite paper by fred harris: fred harris On the Use of Windowing

I am surprised that we do not see any evidence of these harmonics in your frequency plot but this may be because you are only showing a portion of all the frequencies or perhaps because the magnitude is not on a log scale we are not able to make out the harmonics. For example, there should definitely be a signal at three times the fundamental shown. The fundamental appears to be close to 0.04; meaning we should see a harmonic at 0.12; if your frequency of 0.1 represents the Nyquist boundary, then the image of this would be at 0.08 assuming a real signal as you have plotted. (Could you please udpdate your plot to have a log (dB) magnitude scale so we can be sure nothing else is astray?).

That said, we do see that your amplitudes are actually quite close visually from the plot (approx 0.17 in the FFT vs approx 0.19 in the time domain plot), so you must be concerned with the small difference, which is accounted for from the effects described above (the 0.17 is the amplitude of the primary tone as modified by the spectral leakage of your rectangular window and any scalloping loss).

$\endgroup$
  • $\begingroup$ Yes, you are right, I just zoom in the first one, in Fig.3 on my first message we can see the other harmonics. $\endgroup$ – liquid-snake May 12 '17 at 13:38
  • $\begingroup$ What first post? Can you include that plot here. What do you get if you add up all the harmonics? Given the waveform you show they should all be in phase such that I would imagine that the coherent summation of all harmonics will be close to your actual amplitude. $\endgroup$ – Dan Boschen May 12 '17 at 13:40
  • $\begingroup$ Hay Dan, Thanks for your help, my first message is edited, so that's mean its normal to get a small amplitude in the frequency space than the time one ? $\endgroup$ – liquid-snake May 12 '17 at 13:49
  • $\begingroup$ @liquid-snake (Can you plot the vertical axis on a dB scale?) If you are asking if it is normal then I don't think I explained it clearly enough in my answer. Read what I wrote and then let me know what is confusing about that so I can clean it up. I want my answer to be clear enough so that you can answer your own question. But yes what you show is exactly as expected. Also add up the magnitudes in each of the harmonics and let us know what you get compared to the actual amplitude. $\endgroup$ – Dan Boschen May 12 '17 at 13:52
  • $\begingroup$ what do you mean by plot vertical axis on dB scale ? the amplitude of the 4 first pics is : 0.164, 0.153, 0.0036 0.001, and the expected one is 0.1916 $\endgroup$ – liquid-snake May 12 '17 at 14:07
0
$\begingroup$

Due to the Gibbs phenomenon, the only way to measure the peak amplitude of an arbitrary signal that is not a pure sinusoid (or a finite number pure sinusoids with aligned phases and rationally related frequencies) is in the time domain, not by using an FT. When using an FFT or DFT, the pure sinusoidal frequency needs to be integer periodic in the FFT aperture.

$\endgroup$
  • $\begingroup$ Thanks hotpaw2, is it possible to found the formular for this signal y(t) from this FT ?? $\endgroup$ – liquid-snake May 15 '17 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.