bandpass() uses filtfilt(), not filter()!
12 views (last 30 days)
Show older comments
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:
and
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])
0 Comments
Answers (1)
Sudarsanan A K
on 19 Oct 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 ‘iir’ option 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!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!