# Should I shift my fft function?

8 views (last 30 days)
Derick Trinidad on 10 Dec 2019
Commented: Star Strider on 11 Dec 2019
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?
fourier_shift = abs(fftshift(fft(y)));
plot(fourier_shift)

Star Strider on 10 Dec 2019
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:
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.

Show 1 older comment
Star Strider on 10 Dec 2019
I am not sure that playing the Fourier transform as a sound file would be at all meaningful. After taking the absolute value, it is not possible to invert the Foureir transform, (unless you also calculated and saved the phase angles so you could reconstitute the original).
I have never played a Fourier transform as a sound file, so try both and see what works best!
Derick Trinidad on 11 Dec 2019
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 on 11 Dec 2019
As always, my pleasure!