fft second argument function matlab

Hi,
To do the fft I noticed in my homework the second argument is the sampling frequency but I don't understand why. Anyone with a simple explanation? Thank you.

Respuestas (2)

Jan
Jan el 16 de Dic. de 2017
Editada: Jan el 16 de Dic. de 2017
Are you talking about the built-in function fft? Then the 2nd argument is not the sampling frequency. See https://www.mathworks.com/help/matlab/ref/fft.html:
Y = fft(X,n) returns the n-point DFT.
The meaning of n is explained by the formula: https://www.mathworks.com/help/matlab/ref/fft.html#buuutyt-6: It is the sum over n elements.
If you do not mean the built-in fft function, please explain this, because then the readers cannot know, what you are talking about.

2 comentarios

Nuchto
Nuchto el 16 de Dic. de 2017
Thanks, Jan. In my notes from class, I have:
R=fft(audioclip.audio(winbeginning:winbeginning+winLength),audioclip.fs);
As you can see, the audioclip.audio and audioclip.fs are the output s from audioread. Does this make sense? Winbeginning and winlength are just the windows for which the fft is computed.
Jan
Jan el 17 de Dic. de 2017
Well, this might make sense, or in other words, this need not be nonsense. Of course you can use the sampling frequency to define the number of elements for the Fourier transformation. The question is, if you really want this. So please explain, what this code line should achieve. Without knowing this detail, it is impossible to decide, if the code is correct or not. If e.g. winLength is 1, calling fft is nonsense.

Iniciar sesión para comentar.

Star Strider
Star Strider el 16 de Dic. de 2017

0 votos

The audioread (link) function returns only the (Nx2) data, and sampling frequency.
Your function returns a segment of length ‘winLength’ of the data, and (apparently) calculates the Fourier transform of length ‘Fs’. Here, 'Fs' is most likely a 1-second window of the signal.
See fft (link) for documentation on the Fourier transform.

8 comentarios

Nuchto
Nuchto el 16 de Dic. de 2017
Yes, but why using the fs? The length of the audio used (window) is of about 500 samples, so why not using that value?
Star Strider
Star Strider el 17 de Dic. de 2017
It depends on what ‘fs’ is. It likely defines the frequency vector, and therefore is important in producing an accurate estimate (or plot) of the Fourier transformed signal in the frequency domain.
Nuchto
Nuchto el 17 de Dic. de 2017
fs is being used as the number of points used to compute the FFT, so it can be anything as long as it equal or larger than the signal. I can't see why it is important here, because the signal is being windowed.
Star Strider
Star Strider el 17 de Dic. de 2017
I agree.
The core MATLAB fft function simply returns the Fourier transform. I have no idea what your function is doing.
Nuchto
Nuchto el 17 de Dic. de 2017
So then it 'fs' has been used as an arbitrary value for "n" (n-point fft)?
Star Strider
Star Strider el 17 de Dic. de 2017
Without seeing the code in the function, it is impossible to tell. If it is the length of the Fourier transform, then that limits the signal window to one second.
Nuchto
Nuchto el 17 de Dic. de 2017
The fft function is the Matlab inbuilt function. N argument is the n-point value.
Star Strider
Star Strider el 17 de Dic. de 2017
I am aware of that.
If you use the sampling frequency ‘fs’ as the length of the Fourier transform, you may not get all the frequency resolution you otherwise would if your signal is more than one second long. I always use either the length of the signal, or nextpow2 of the length to specify the Fourier transform length.

Iniciar sesión para comentar.

Categorías

Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Dic. de 2017

Comentada:

el 17 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by