doubt fft with values

3 vues (au cours des 30 derniers jours)
Julian Oviedo
Julian Oviedo le 9 Oct 2016
Commenté : Star Strider le 10 Oct 2016
If you see, there is sin( 2 pi 15* t) signal and I want to show the spectrum of it. The problem what I see it's that there are 2 impulses, ones on 15 Hz (it's right) but other on 35 Hz. And the other problem it's that the signal magnitude is approximately 200 but the signal has an amplitud of 1.

Réponse acceptée

Julian Oviedo
Julian Oviedo le 10 Oct 2016
Modifié(e) : Julian Oviedo le 10 Oct 2016
Thanks. I work!, but I do not understand why I should divide the fft(x)'s vector by lenght(x).
For example in the next picture, the max lobule must to be on 100 Hz. why not is there?

Plus de réponses (1)

Star Strider
Star Strider le 9 Oct 2016
If you want to plot a two-sided Fourier transform, you need to define your frequency vector differently and use the fftshift function:
t = 0 : 1/50 : 10-1/50;
x = sin(2*pi*15*t);
y = fft(x)/length(x);
m = abs(y);
a = angle(y);
f = -25: 1/10 : 25-1/10;
figure(1)
subplot(2,1,1)
plot(f, fftshift(m))
grid
subplot(2,1,2)
plot(f,a)
grid
figure(2)
plot(t, x)
grid
axis([0 1 -1 1])
To plot a one-sided Fourier transform, see the R2015a documentation for the fft (link) specifically the code between the first (top) two plot figures.
  2 commentaires
Star Strider
Star Strider le 10 Oct 2016
Julian Oviedo’s ‘Answer’ moved here:
why do you do y = fft(x)/length(x);
it's because the library fft or what?
Sorry for be insistent but I need to know to work in the future with this
Star Strider
Star Strider le 10 Oct 2016
The fft as calculated does not normalise by the energy in the signal, so it is necessary to do that in your code by dividing by the length of the original signal. See the documentation for fft and textbook discussions of the fast Fourier transform. The fft code does not do this because it is common to zero-pad the original signal to increase the frequency resolution, increase the computational efficiency of the fft calculation, or both. The fft code ‘sees’ only the signal that you give it, not the original signal without the zero-padding. Zero-padding adds no energy to the signal, so dividing the Fourier-transformed signal by the length of the padded signal would give an erroneous result.
If my Answer solved your problem, I would have hoped for you to Accept it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by