File Exchange

image thumbnail

FFT, PSD, and CSD

version 1.0.2 (2.82 KB) by Ayad Al-Rumaithi
Fast Fourier Transform, Powder Spectral Density, and Cross Spectral Density

40 Downloads

Updated 15 May 2019

View License

function Result=FFT(x, Fs)

Fast (Discrete) Fourier Transform of a Signal

inputs
x : input sequence (1*Ndata)
Fs: sampling frequency

outputs
Result structure consists of
Result.f : frequency (1*NumUniquePts)
Result.MX : amplitude (1*NumUniquePts)
Result.Arg : Phase Angle (1*NumUniquePts)

------------------------------------------------------------------
function Result=PSD(x, Fs,window,N,p)

Power Spectral Density of a Signal (This function do the averaging for the spectral density)

inputs
x : input sequence (1*Ndata)
Fs: sampling frequency
window : window size
N: Number of windows
p: overlap ratio of windows

outputs
Result structure consists of
Result.f : frequency (1*NumUniquePts)
Result.MX : amplitude (1*NumUniquePts)

------------------------------------------------------------------
function Result=CSD(x,y,Fs,window,N,p)

Cross Spectral Density of a Signal (This function do the averaging for the spectral density)

inputs
x : input sequence 1 (1*Ndata)
y : input sequence 2 (1*Ndata)
Fs: sampling frequency
window : window size
N: Number of windows
p: overlap ratio of windows

outputs
Result structure consists of
Result.f : frequency (1*NumUniquePts)
Result.MX : amplitude (1*NumUniquePts)
Result.Arg : Phase Angle (1*NumUniquePts)

Cite As

Ayad Al-Rumaithi (2019). FFT, PSD, and CSD (https://www.mathworks.com/matlabcentral/fileexchange/69634-fft-psd-and-csd), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Description added. windowing is based on Bartlett's method to to get more accurate spectrum
https://en.wikipedia.org/wiki/Bartlett%27s_method

thanks Ayad, thanks for shareing your code.
could you please comment it? e.g. can the functions be used for multiple trials ?, if so what are the dimensions of the input should be? what are the effect of the window size?
thanks

Updates

1.0.2

description

1.0.1

Functions are fixed regarding normalization. Description is added

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor