cornerFreqs automatically detects appropriate bandpass filter corner
frequencies by comparing the input signal's spectrum with the noise spectrum.
Processing of seismic waveforms often requires bandpass filtering.
Selection of filter corner frequencies has been not only a manual
process but also subjective. There is a need for automatically
detecting corner frequencies for processing a large number of seismic
First, "PphasePicker" function (Kalkan, 2016) is used to determine
P-phase arrival time (event onset) to get the background noise. Next, Fourier amplitude spectra for noise and signal are calculated. These two spectra are smoothed using "smoothSpectra" function. Finally, intersection points of the smoothed spectra within low-pass and high-pass frequency regions are searched to determine the appropriate corner frequencies to be used for bandpass filtering.
High-pass region is defined between 0.1 Hz and 1 Hz. If no intersection
point detected, default value of 0.1 Hz is used.
Low-pass region is defined between the characteristic frequency
of the recording instrument (fc) (often 25 Hz) and Nyquist (half of
sampling frequency of waveform data). If no intersection point detected, 80% of Nyquist is used.
This code uses the following external functions:
 PphasePicker.m --> This function computes P-Phase onset time,
also available at MatLAB FEX
 smoothSpectra.m --> This function smooth FAS using Konno-Ohmachi
window, also available at MatLAB FEX
[hp_freq, lp_freq] = cornerFreqs(x,dt)
x = broadband velocity or acceleration data in
single-column format (1xn) or (nx1)
dt = sampling interval in second (e.g., 0.005)
VALID PROP_NAME / PROP_VAL PAIRS:
'plot_name' --> [text]-[default: None]
'plot_path' --> [text]-[default: None]
'debug' --> [text]-[default: False]
hp_freq = high-pass corner frequency in Hz
lp_freq = low-pass corner frequency in Hz
see demo.m file
cornerFreqs function does not require any MatLAB toolbox.
In preparing this function, I benefitted from Curve Intersections
(InterX.m) function written by NS, which is available at MathWorks FEX.
Kalkan, E. (2016). “An Automatic P-phase Arrival Time Picker“, Bulletin of Seismological Society of America,106(3): 971-986, doi: 10.1785/0120150111
If you find this code useful for your application, please don't forget to rate it.
For questions / suggestions / comments and bug reports: firstname.lastname@example.org
Dr. Erol Kalkan, P.E. (2020). AUTODETECT BANDPASS FILTER CORNER FREQUENCIES (https://www.mathworks.com/matlabcentral/fileexchange/70270-autodetect-bandpass-filter-corner-frequencies), MATLAB Central File Exchange. Retrieved .
code is even more simplified
Updated notes, fixed typo.
More updates on the notes
Plp and Php computations updated for speed