bandpass() uses filtfilt(), not filter()!

4 views (last 30 days)
Prakash S R
Prakash S R on 25 Apr 2022
More a heads-up than a question:
The Signal Processing Toolbox function bandpass() designs and applies a filter on the input signal.
The function documentation claims:
[y,d] = bandpass(___) also returns the digitalFilter object d used to filter the input.
and
Use filter(d,x) to filter a signal x using d
In reality, if you want to get the same output y as bandpass(), you will need to do filtfilt(d,x).
This could be an issue if you are expecting bandpass() to give the output of a causal filter - it is in fact output of a delay-compensated anti-causal filter of double the order of d
x = randn(1e4,1);
[y, d] = bandpass(x, [0.2 0.3], 'ImpulseResponse', 'iir', 'Steepness', 0.75);
f_x = filter(d,x);
ff_x = filtfilt(d,x);
plot(y, 'LineWidth', 3);
hold all;
plot(f_x, 'or-');
plot(ff_x, '*g-');
xlim([4000, 4100])

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by