output filter from bandpass function
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 16 May 2018
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 Comments
More Answers (0)
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!