Should I shift my fft function?

조회 수: 21 (최근 30일)
Derick Trinidad
Derick Trinidad 2019년 12월 10일
댓글: Star Strider 2019년 12월 11일
Good afternoon,
I'm trying to take the fourier transform of a recorded file. Do i need to apply the function shiftfft to the signal? If so, how do I plot the signal correctly and how do I read the graph?
%Read Voice
[y,fs] = audioread('Testing.m4a');
fourier_shift = abs(fftshift(fft(y)));
plot(fourier_shift)

채택된 답변

Star Strider
Star Strider 2019년 12월 10일
It depends on the result you want. The shifted version plots the negative and positve frequencies (the Fourier transform is symmetric). The unshifted version (plotting only half of the result) is generally more informative.
The two options:
%Read Voice
[y,fs] = audioread('Testing.m4a');
L = size(y,1);
fourier_shift = abs(fftshift(fft(y)/L));
Fn = fs/2;
freqvct = linspace(-Fn, Fn, L);
figure
plot(frqvct, fourier_shift*2) % Two-Sided, With Frequency Vector
grid
fourier = abs(fft(y)/L);
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel (Fv);
figure
plot(Fv, fourier(Iv)*2) % One-Sided, With Frequency Vector
grid
Choose the option you want.
  댓글 수: 4
Derick Trinidad
Derick Trinidad 2019년 12월 11일
Yeah, that was a silly question. I didn't realize till much later that I didn't need to play the audio of the Fourier transform for my assignment. Thanks anyways though.
Star Strider
Star Strider 2019년 12월 11일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by