File Exchange

image thumbnail


version (317 KB) by Bryant Svedin
findFFT returns fft amplitude and frequency vectors from input data


Updated 12 May 2010

View License

findFFT returns fft amplitude and frequency vectors from input data, with options to return normal fft, zeropadded fft, windowed fft, or both windowed and zeropadded to remove spectral leakage.

data - vector containing information to perform fft on
'-sampFreq',## - inputs sampling frequency of ##, if ## is not supplied default is 1
'-zeropad',## - option to zeropad data to ## times original size, if ## is not supplied default is 10
'-window' - Option to apply a windowing function to data
'windowtype' - string containing which windowing function to apply to data, must follow option '-window', if not supplied default is 'hann'
amp - vector containing amplitude values (y-axis)
freq - vector containing frequency values (x-axis)

[amp freq] = findFFT(data)
[amp freq] = findFFT(data,'-sampFreq',10)
[amp freq] = findFFT(data,'-zeropad',5)
[amp freq] = findFFT(data,'-window','hamming')
[amp freq] = findFFT(data,'-sampFreq',10,'-zeropad',5,'-window','blackman')

Use plotFFTdifs.m script to see examples of how this function works and what all the different outputs look like.

For an excellent introduction to FFTs, zeropadding, and windowing

For an excellent article on windowing

Written by:
Bryant Svedin
10 May, 2010

Cite As

Bryant Svedin (2020). findFFT (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

paul harder

Scott Richardson

Wow, awesome program! Thank you much, Bryant.

Bryant Svedin

Having never used simulink I can't say for certain how to do it. But after doing a little looking it looks like you should be able to just use the user defined function block and copy the code from findFFT into it.
Hope that helps


hye there, just want to ask how can I implement this code to display the spectrum of a signal in SIMULINK?

Thanks in advance for your reply

Bryant Svedin

Please comment. I would really appreciate suggestions (or praise if you wish).

MATLAB Release Compatibility
Created with R2009a
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!