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

29 visualizzazioni (ultimi 30 giorni)
Prakash S R
Prakash S R il 25 Apr 2022
Risposto: Sudarsanan A K il 19 Ott 2023
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])

Risposte (1)

Sudarsanan A K
Sudarsanan A K il 19 Ott 2023
Hello Prakash,
I understand that you are referring to the MathWorks documentation of the function “bandpass()” in https://mathworks.com/help/releases/R2022a/signal/ref/bandpass.html.
In the same documentation at https://in.mathworks.com/help/releases/R2022a/signal/ref/bandpass.html#d123e2931, it is mentioned that the function compensates for the delay. Specifically, for the ‘iiroption for the “ImpuseResponse” property, it is also mentioned that it uses “filtfilt()” function, as you validated with your example code.
In the documentation of “bandpass()” function in subsequent releases, for example at https://in.mathworks.com/help/releases/R2022b/signal/ref/bandpass.html#d124e3329, it is also mentioned that “Unlike bandpass, the filter function does not compensate for filter delay. You can also use the filtfilt and fftfilt functions with digitalFilter objects.
I hope this helps!

Categorie

Scopri di più su Digital and Analog Filters in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by