FFT, dominant frequency doesnt match time domain?
20 views (last 30 days)
Show older comments
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
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.
Accepted Answer
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
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.
More Answers (0)
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!