doubt fft with values

2 ビュー (過去 30 日間)
Julian Oviedo
Julian Oviedo 2016 年 10 月 9 日
コメント済み: Star Strider 2016 年 10 月 10 日
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.

採用された回答

Julian Oviedo
Julian Oviedo 2016 年 10 月 10 日
編集済み: Julian Oviedo 2016 年 10 月 10 日
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?

その他の回答 (1 件)

Star Strider
Star Strider 2016 年 10 月 9 日
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 件のコメント
Star Strider
Star Strider 2016 年 10 月 10 日
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 2016 年 10 月 10 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by