output filter from bandpass function

조회 수: 2 (최근 30일)
Tally
Tally 2018년 5월 16일
답변: Star Strider 2018년 5월 16일
Hi, I am using the bandpass function in the following code:
Fs = 10;
t = 1:(1/Fs):200;
s = sin(2*pi*0.1*t) + sin(2*pi*0.5*t);
[y,d] = bandpass(s,[0.06,0.12],Fs);
y2 = filter(d,s);
According to matlab documentation d is the Bandpass filter used in the filtering operation, returned as a digitalFilter object. So I expect y2 to be equal to y1, however they are very different. My questions are: 1. Why y2 is different than y1? 2. How can I use d to obtain exactly y1? Thanks,

채택된 답변

Star Strider
Star Strider 2018년 5월 16일
The filter function will only return the same result as ‘y’ (or ‘y1’) for linear-phase FIR filters such as those produced by the fir1 function. For IIR filters, the default design of the bandpass function, you must use the phase-neutral filtfilt function, as I suspect the bandpass function uses by default.
I will let you explore those functions at your leisure.
Your code (with my slight modifications) becomes:
Fs = 10;
t = 1:(1/Fs):200;
s = sin(2*pi*0.1*t) + sin(2*pi*0.5*t);
[y,d] = bandpass(s,[0.06,0.12],Fs);
y2 = filtfilt(d,s);
figure(1)
plot(t, s, t, y2, t, y)
figure(2)
plot(t, y2, '-', t, y, '--')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by