fft_spectrum

Function to plot the FFT power spectrum of continuous time-series data with time in days or datenum
184 Downloads
Updated 3 Apr 2022

View License

This function makes spectral power density plots for continuous time-series data, for example oceanography data collected from moorings, hydrolab data from water quality studies or data sondes, or any continuous time series data set with equal time intervals in units of days and no missing data. If there are any missing data the missing values will be replaced with the mean of all the time-series data.
For example, to plot spectral density of time-series data for tide heights, dissolved oxygen, pH, temperature, salinity, etc.
The output from fft_spectrum is a figure and png file with two panels:
a. time series plot
b. plot of the FFT power spectrum of frequencies for the data
% load example data set of tide heights in Mar-Jun 2018 in Puget Sound
load fft_spectrum_example_data
% run the fft_spectrum function on the example data set
fft_spectrum(jdatenum, depth, 'Tide Height', 'm', 3);

Cite As

Gregory Pelletier (2024). fft_spectrum (https://www.mathworks.com/matlabcentral/fileexchange/109274-fft_spectrum), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.4

moved the test for missing values before the test for odd number of input values in the time-series in case both problems with the input data need to be fixed

1.0.3

added code to replace any missing values in the time-series data with the mean of all of the data

1.0.2

corrected typo in yaxis units label for power spectrum plot

1.0.1

corrected typo in yaxis units label for power spectrum plot

1.0.0