image thumbnail

Amplitude and Phase spectra of a signal (Fourier transform)

version 2.0 (4.38 KB) by Afshin Aghayan
Calculating the amplitude spectrum with the desired frequency resolution and Improving Phase spectrum with thresholding


Updated Tue, 28 Apr 2020 08:53:22 +0000

View License

ft_spect (version 2.0) calculates Amplitude and Phase spectra of an input signal with the desired frequency resolution and also filters the Phase spectrum for suppressing the floating rounding-off error.

NOTICE#1: ft_spect can NOT remove the spectral leakage.

NOTICE#2: Discrete Fourier transform (DFT) looks at the input signal as one period of a periodic signal and discretizes the frequency spectrum of this periodic signal based on the length of the input signal. For a signal with sampling frequency Fs, over the time of T=NΔt, the frequency bins (a.k.a frequency resolution in the meaning of distinguishing frequency of f1 from f2) are spaced Δf=1/T=Fs/N; thus, the frequency resolution of DFT only depends on the length of the input signal (T). BUT, zero-padding does NOT increase the frequency resolution and does NOT reveal more information about the spectrum; it only interpolates amplitudes between bins. For increasing the spectral resolution, a long duration of measurements is necessary, because DFT looks at the input signal as one period of a periodic signal; therefore, repeating the input signal is acceptable and doesn't produce any artifacts. BUT, in this case, the length of the input signal is increased, and consequently, the spectral resolution also increases.

NOTICE#3: Phase spectrum because of floating rounding-off error is very noisy. Small rounding-off error in the "arctan" calculation produces significant noise in the result of the phase spectrum. For suppressing this kind of noise, ft_spect uses a threshold filtering. It means if the amplitude of specific frequency is less than the predefined threshold value, it put zero instead of it.


Afshin Aghayan, Priyank Jaiswal, and Hamid Reza Siahkoohi (2016).
"Seismic denoising using the redundant lifting scheme." GEOPHYSICS, 81(3), V249-V260.

** Please share your suggestions and idea for improving ft_spect
through or

Version 1.0 (Spring 2017) ft_spect v1.0 is written and tested in MATLAB R2013a.

Version 2.0 (Spring 2020) the following changes are applied:

1) You can define your desired frequency resolution (Δf)
2) It is much faster than the v1.0
3) Added an example for comparing the output of the usual FFT and this program (Only type ft_spect for DEMO; look at ft_spect_demo function at the end of the program for more details)

Afshin Aghayan

Cite As

Afshin Aghayan (2022). Amplitude and Phase spectra of a signal (Fourier transform) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!