FFT of Step Input using Gans-Nahman Method

Version 1.0.0 (1.77 MB) by Emma Farnan
This code provides a robust calculation of the spectral response for a unit step-like input for multiple concurrent signals
9 Downloads
Updated 6 Jun 2023

View License

Calculating the Discrete Fourier Transform (DFT) of non-periodic signals will produce large artifacts caused by the underlying periodicity assumptions that attempt to reconcile the offset from the pre- to post-step data. As a step response is transient by nature, detrending techniques can't be used to improve the spectral calculation. Additionally, attempts to convolve the signal with windows such as the Hanning window solve the end-point discontinuity but negatively impact the spectral outcome.
Gans-Nahman published a method to turn step-inputs into duration-limited signals by appending a reflected version of the signal to the end of the original step response. This code outputs the spectra from this improved procedure and can also output the constructed waveform if desired.
Requirements:
This function can handle multiple step-like signals provided that they share all correspond to the same time vector where time = 0 indicates the initial response to a step input (ie. any dead-time has been removed). Data must exist prior to t = 0, and each of the signals must be normalized such that the signal is 0 for t < 0 and it approaches 1 as it reaches equilibrium.
Included Example:
The mat file GNexamp.mat is included to show the operation of the code. The mat file should include an Nx1 time vector t spanning from -7 to 35 ms, Nx2 data vector d, and sampling frequency Fs.
[f,F0] = GansNahmanFunc(t,d,2.75,Fs,"A");
After loading in the example mat data, inputting the above line will reproduce the time-domain waveforms seen in this code's thumbnail. "A" represents one of the preset Low-pass filters included (Chebyshev Type II at 50 kHz). Changing 2.75 to other values will change the time-domain signal included but will minimally affect the spectra. For the included data, this value should not exceed ~7.5 ms where the "step-input" portion of the signal ends. Omitting "A" will skip the low-pass filtering entirely.
The function can be modified to output the time series data by adding dgn and dorig to the outputs of the function. These are structures that include the constructred time signal (ex: dgn.t) and the constructed data signals (ex: dgn.d).
Comments:
The function was originally written for data sampled at 5 MHz for ~50 ms. As such the code is written to expect the time vector in milliseconds and the sampling frequency in Hz. Efforts were made to make this version as robust and flexible as possible so Warnings or errors should occur if the t and Fs are not in these relative units. An additional leftover from the original version of this code is the optional inclusion of Low-Pass Filters. These filters are applied before the reflected wave reconstruction if the region of interest is far below the Nyquist frequency. To use existing filters or to input new ones, the DSP System Toolbox is required as it uses fdesign.lowpass to generate the filter. Lastly, there are plots that can be generated in this function, by toggling skipAllPlots to true, all of the plots will be supressed.
Citation for Gans-Nahman paper:
Gans, W. L., and Nahman, N. S. “Continuous and Discrete Fourier Transforms of Steplike Waveforms.” IEEE transactions on instrumentation and measurement, Vols. IM-31, No. 2, 1982, pp. 97–101. https://doi.org/10.1109/TIM.1982.6312529.

Cite As

Emma Farnan (2024). FFT of Step Input using Gans-Nahman Method (https://www.mathworks.com/matlabcentral/fileexchange/130649-fft-of-step-input-using-gans-nahman-method), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
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!
Version Published Release Notes
1.0.0