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

15 visualizaciones (últimos 30 días)
Prakash S R
Prakash S R el 25 de Abr. de 2022
Respondida: Sudarsanan A K el 19 de Oct. de 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])

Respuestas (1)

Sudarsanan A K
Sudarsanan A K el 19 de Oct. de 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!

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by