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

조회 수: 12 (최근 30일)
Prakash S R
Prakash S R 2022년 4월 25일
답변: Sudarsanan A K 2023년 10월 19일
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])

답변 (1개)

Sudarsanan A K
Sudarsanan A K 2023년 10월 19일
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!

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by