FFT, dominant frequency doesnt match time domain?

20 views (last 30 days)
Hi
I have mutiple (relativly) noisy sine waves that i need to analyse (signal at 256Hz). A major assumption in my project is that i am aware of the frequency. So i ran an FFT in order to detremine the amplitudes. However, i seem to run into an issue with some sinewaves, were the expected frequencies are not correct. This following code seems to have an impact before i run the fft on the signal.
tendIn=size(y,2)/256;
tendFFT=tendIn-mod(tendIn,Tw);
tendFFTindex=(tendFFT*256)-mod(tendFFT*256,2);
y=y(1:tendFFTindex);
For example: I expect a dominant sine wave frequency of 0.2Hz and when i leave the code above it shows just that. But when i plot it in time domain it seems that frequncy is off (and so is the ampltiude). Now if i comment the above code and run the FFT on the data directly i seem to acheive the right frequency (which would make my assumption that the frequency is 0.2Hz incorrect).
This occurs on some of the sinewaves. I want to go with my gut instinct and trust that the time domian is correct (and my assumption is wrong) but the above code seems to make sense so i dont know were i went wrong.
Note: This wave may or maynot be impacted by reflected wave (same sinewave reflected).However, all sinewaves would be effected yet not all have this promblem.
Thanks
  4 Comments
dpb
dpb on 10 Jun 2021
So attach a .mat file or the code to generate/illustrate the specific cases with what you think is a problem...we still can't diagnose what we can't see.
Mohammed Elmezoghi
Mohammed Elmezoghi on 10 Jun 2021
Sorry, I had to rewrite some of the code. I have attached the code. Hope it demonstrates my point.
Thank you

Sign in to comment.

Accepted Answer

dpb
dpb on 11 Jun 2021
Your problem is simply that the dominant frequency isn't the same as one of the frequency bin midpoints depending on the number of elements in the FFT
When the sample frequency is fixed at 256 Hz, then the frequency resolution is Fs/L and that may not be precisely divisible by 0.2000 Hz.
In your first case it is, in the second it isn't.
To see what's happening, plot the PSDs and compare --
You see both estimated the frequency as close as they could, just in the first case the center frequency is precisely centered on 0.2 Hz, in the second the closest frequency bin to 0.2 Hz is 0.1875 Hz so there's power in noncomputed bins on either side. Similarly, owing to the noise, you see spreading of energy around the nominal 0.2 Hz in the even case as well; the integral of the two peaks for the total power will be pretty similar.
You would probably get better results if you also were to use a windowing function and then if it is true that you do always know precisely the input signal frequency, then use NFFT to match the bin center frequency to the known frequency.
Your resulting time trace is out of whack because you used the bin center frequency which is off by enough that it really shows up over a number of cycles.
  4 Comments
Mohammed Elmezoghi
Mohammed Elmezoghi on 11 Jun 2021
Intresting. I have accepted this answer.
Further questions if you wish to answer:
Just to confirm my understanding the intial code that minimises the signal to fit whole sine waves is the correct process?
Also, if the "real" frequency is slightly off from the bin centre, then from the plots such "real" frequency for this signal should be closer to 0.185Hz than 0.2Hz, as the 0.185Hz is a better fit?
Could you possibly explain why it appears that there is more spread and less amptlitude in case(1) than (2), yet in the noise-free figure the case(1) has less spread and more ampltiude? My opinion based on the above answer and limited knowldge would be that the incorrect bin size spacing (case(2)) would result in less accurate modelling of signal noise, as it results in adding the spread to the 0.185Hz bin. Is this understanding correct?
Thank You
dpb
dpb on 11 Jun 2021
You have to integrate the whole peak to get the total energy, not just use the single bin point estimate.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!