Azzera filtri
Azzera filtri

why we need to multiply x axis with SAmpling frequency and divide it by length of FFT

13 visualizzazioni (ultimi 30 giorni)

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 Commento
cr
cr il 1 Dic 2022
Modificato: cr il 1 Dic 2022
Remove the multiplication and division and see what you get. Try and interpret the result. Introduce the multiplication and division one at a time and see how it affects the result. #joyoflearning

Accedi per commentare.

Risposte (1)

V Sairam Reddy
V Sairam Reddy il 8 Dic 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.

Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by