Question on use of fft and using positive frequency values only

8 ビュー (過去 30 日間)
Hendrik2k1
Hendrik2k1 2022 年 6 月 2 日
編集済み: Paul 2022 年 6 月 2 日
I have two outputs of an carried out fft from filtered signal. I now that there is only a 770 Hz sin signal left in x_filtered, sample frequency fs is 48000.
fft_xf_shift = fftshift(fft(x_filtered,fs));
m_sh = abs(fft_xf_shift);
Seems to me that fft gives out a double sided frequency spectrum. With fftshift I zero-center the spectrum. Next I calculate the absolute values and then save in m_pos only the positive values because the negative frequency values are of no intereset in this case.
Next I plot the 20*log10 magnitude over frequency:
m_pos = m_sh(fs/2+1:fs);
f=0:1:fs/2-1;
figure;
plot(f,20*log10(m_pos/max(m_pos)))
The plot give the correct magnitude at 770 Hz. Even if I have the highest magnitude reading at 770 Hz in the final plot, when I plot m_pos, which is the right snipped of the fft_shifted value, the highest reading is at 771 Hz or at position 771 of the vector.
I certainly have a misconception here. Can you help me? Thank you.

採用された回答

Paul
Paul 2022 年 6 月 2 日
編集済み: Paul 2022 年 6 月 2 日
Is this just an indexing question? If I understand the code snippet correctly, the frequency vector starts at 0, and incremented by 1, so f(771) = 770. So the peak would also be at m_pos(771), corresponding to 770 Hz.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by