Fourier filter function for time-series signal vector y; 'samplingtime' is the total duration of sampled signal in sec, millisec, or microsec; 'centerfrequency' and 'frequencywidth' are the center frequency and width of the filter in Hz, KHz, or MHz, respectively. If shape = 1, the filter is Gaussian; as shape increases, the filter shape becomes more and more rectangular (faster cut-off rate). Set mode = 0 for band-pass filter, mode = 1 for band-reject (notch) filter.
Example: plot(FouFilter(tan(1:1000),15,2,2,0))
| Interactive Fourier Filter script for data in global variables x,y. Requires Matlab 6.5. To use it, place the signal in the global variables x,y (x = independent variable, e.g. time, and y = dependent variable, e.g. signal amplitude) and then execute this m-file. The filtered signal is returned in the global vector ry. (There is also a version written as a function, iff(x,y), that works similarly and returns the filtered signal as the value of the function.)
The bottom plot shows the power spectrum of the original signal (in blue) and the spectrum of the filter (in red). The x-axis of this plot is frequency, in the reciprocal units of the signal's independent variable x (e.g. Hz if the signal is in seconds, KHz if the signal is in milliseconds, etc). In this version, the original and filtered signals are displayed in separate windows. (To display the original signal and filtered signal superimposed in the same window, rename AlternativeRedrawFourierFilter.m to RedrawFourierFilter.m)
There are 4 sliders for interactive control of the filter parameters: (If the range of the sliders is inappropriate for your signal, you can adjust the slider ranges in lines 43-45). |
| Self-contained demonstration of Interactive Fourier Filter with sliders for interactive control. Requires Matlab 6.5. The Signal slider selects from five different signals (you can change these in the function iffsignal.m). The Center slider controls the center frequency of the filter, the Width slider controls the width, and the Shape slider controls the shape of the pass band. If shape = 1, the filter is Gaussian; as shape increases, the filter shape becomes more and more rectangular. The Mode slider has only 4 settings: mode=0 for band-pass filter, linear plot; mode=1 for band-pass filter, semilogx plot; mode=2 for band-reject (notch) filter, linear plot; mode=3 for band-reject (notch) filter, semilogx plot. In this version, the original and filtered signals are displayed in separate windows. To display the original signal and filtered signal superimposed in the same window, rename AlternativeRedrawFourierFilter.m to RedrawFourierFilter.m |
|
|
Simple self-contained fourier filter script, without interactive sliders, for simulated time-based signal, where
x = time in sec, millisec, or microsec. Original signal (blue)
and filtered signal (red) are displayed superimposed in the top
window, power spectrum and filter spectrum in bottom window.
'samplingtime' is the total duration of sampled signal, in seconds
(or millisec or microsec). 'samplerate' is the sample rate in Hz (or
KHz or MHz). 'centerfrequency' is the center frequency of the filter,
and 'frequencywidth' is the frequency width of filter, in Hz (or KHz
or MHz). 'Center' and 'width' are the center harmonic and width of
the filter band expressed in harmonic number. 'Shape' determines the
sharpness of the cut-off. If shape = 1, the filter is Gaussian; as
shape increases the filter shape becomes more and more rectangular.
Set mode = 0 for band-pass filter, mode = 1 for band-reject (notch) filter.
T. C. O'Haver (toh@umd.edu), version 1.5, May, 2007 |
Tom O'Haver
Professor Emeritus
Department of Chemistry and Biochemistry
The University of Maryland at College Park
toh@umd.edu
http://www.wam.umd.edu/~toh