idealfilter
Applies an ideal frequency-domain filter to a timeseries.
Category: Language Fundamentals > Data Types
Syntax
tsout = idealfilter(ts, interval, 'pass')
Keeps the frequencies inside each interval.
tsout = idealfilter(ts, interval, 'notch')
Removes the frequencies inside each interval.
Description
The filter works in the frequency domain: the data are transformed with an FFT, the unwanted frequency bins are set to zero, and the inverse transform gives the filtered signal. The cut is perfectly sharp, which is why it is called ideal, but also why it can ring near abrupt changes.
Input arguments
tstimeseriesobject.interval- Two-column matrix of frequency bands
[low high], in cycles per time unit of the series. 'pass' | 'notch'- Whether the bands are kept or removed.
Output arguments
tsout- Filtered
timeserieswith the same time vector.
Example
Low-pass of two tones
t = (0:7)';
y = sin(2*pi*0.05*t) + sin(2*pi*0.4*t);
f = idealfilter(timeseries(y, t), [0 0.2], 'pass');
disp(round(f.Data' * 1000) / 1000)
Output
-0.4450 -0.4260 -0.1580 0.2030 0.4450 0.4260 0.1580 -0.2030