output filter from bandpass function
2 ビュー (過去 30 日間)
古いコメントを表示
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,
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Digital Filter Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!