I have been given a digital bandpass filter - what is it?
6 views (last 30 days)
Show older comments
I have been given a code snippet for a digital bandpass filter. I have no idea where the author got it from or how he derived it.
% Creates y being the BandPass filtering of input signal x. The BandPass will
% accept components of wavelength *period* plus or minus about *delta*%.
% Others should be rejected.
period = 30;
delta = 0.20;
beta = cos(2*pi()/20);
gamma = 1/cos(4*pi()*delta/period);
alpha = gamma - sqrt(gamma*gamma - 1);
y(1,1)=0;
y(2,1)=0;
for i = 3:3000 % We only filter first 3000 rows of x
y(i,1) = 0.5*(1-alpha)*(x(i,1)-x(i-2,1)) + beta*(1+alpha)*y(i-1,1) - alpha*y(i-2,1);
end
If used with Period=30 and Delta=0.20 it should capture about 20% of the cyclic behaviour around a wavelength of 30 data points.
Do any of you know the mathematical derivation or family that he has used? For example is this a Butterworth, Chebyshev Type I Filter etc?
0 Comments
Answers (3)
Wayne King
on 19 Dec 2011
At first glance, it doesn't look familiar, but do you have the Signal Processing Toolbox? You can easily design bandpass filters using fdesign.bandpass
0 Comments
Daniel Shub
on 19 Dec 2011
It is not a notation I am familiar with. But it looks like beta, gamma, and alpha are scalars and Q is unused. If that is correct then letting y = BP and x = Price gives:
y = ax-ax[2]+by[1]-cy[2]
That almost looks like a filter, but I don't understand what ax means, are you sure it is not Price[1]-Price[2]? Also I would expect it to look like:
y[n] = 0*x[n]+ax[n-1]-ax[n-2]-by[n-1]-c[n-2]
8 Comments
Daniel Shub
on 20 Dec 2011
It looks much better and is now a much harder question. I will have a think about it.
Wayne King
on 20 Dec 2011
Hi Stewart, this is a standard 2nd order linear constant coefficient difference equation. You can mimic this filter easier in MATLAB with
B = [0.5*(1-alpha) -0.5*(1-alpha)];
A = [1 -beta*(1+alpha) alpha];
% view the filter magnitude response
fvtool(B,A);
% filter data
output = filter(B,A,input);
The filter is a bandpass filter with a narrow passband at pi/10 radians/sample. What period that actually corresponds to depends on the sampling frequency of the data.
To answer your question, the design equations look like a Chebyshev type II approximation to me.
You can design a Chebyshev type II filter using fdesign.bandpass and specifying the design method as 'cheby2'
3 Comments
Wayne King
on 20 Dec 2011
@Daniel Thank you for pointing out that omission, I have added that information.
See Also
Categories
Find more on Audio Processing Algorithm Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!