why we need to multiply x axis with SAmpling frequency and divide it by length of FFT
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Im new to matlab im doing a simple FIR design i got stuck at particularly one line that is
nfft = 2.^nextpow2(length(x));
fy = fft(x,nfft);
fy = fy(1:nfft/2);
xfft = Fs*(0:nfft/2-1)/nfft;%why????????????
plot(xfft,abs(fy/max(fy)));
% Im not getting why xfft is calculated in that way sombody please help!!
1 commentaire
Réponses (1)
V Sairam Reddy
le 8 Déc 2022
Hi Abhay,
I understand that you want to know why Fs/N is being multiplied to the X-axis.
Here are some things to help you understand:
- The number of points in the time domain equals to number of points in frequency domain which is N.
- The FFT shows frequency domain view of time domain signal in frequency space of -Fs/2 to Fs/2.
- This frequency space is split into N equally spaced points leading to a gap of Fs/N between the consecutive points.
- That means, if a frequency component is at freq=0, the next component will be at freq=1*Fs/N, the next will be at freq=2*Fs/N, and it goes on till (N-1)*Fs/N.
- The frequency spectrum is periodic, hence all the components from [-Fs/2, 0] are again repeated in [Fs/2, Fs].
- The FFT function gives the positive frequency components first and then the symmetric negative frequency components making the frequency range [0, Fs]. Hence, we only consider first half of the spectrum.
- Hence the X-axis corresponds to the frequencies and the Y-axis corresponds to the magnitude of that corresponding frequency present in the signal.
Hope this helps you understand. Please refer to this MATLAB Answer - If a fft of vector x is plotted then what would be the x-axis? to get some more insights.
0 commentaires
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!