How to create a second order bandpass filter. (Sallen-key bandpass filter)
7 views (last 30 days)
Show older comments
I need to code a bandpass filter using the given transfer function:
H(s)=((h(w/Q)*s)/((s^2) + (w/Q)*s+w^2))
w=2*pi*5000
Q factor is 2
h=5
The aim is to plot the magnitude of the transfer function.
I have tried to use the syntax fdesign.bandpass but do not know how to compile the specstring. Thanks in advance for your assistance!
0 Comments
Answers (1)
Star Strider
on 30 Sep 2016
First, use the Symbolic Math Toolbox to do the (error-free) algebra and substitutions and create the polynomial vectors, then use the Signal Processing Toolbox freqs function to plot the transfer function (Bode plot):
syms s
w = sym(2*pi*5000);
Q = sym(2);
h = sym(5);
H(s) = ((h*(w/Q)*s)/((s^2) + (w/Q)*s+w^2)); % Substitute Values
H = simplify(H, 'steps',10); % Simplify
[Hn,Hd] = numden(H); % Separate Numerator & Denominator Polynomials
Hnp = sym2poly(Hn) % Convert To Double Polynomial
Hdp = sym2poly(Hd) % Convert To Double Polynomial
figure(1)
freqs(Hnp, Hdp) % Bode Plot
If you want to create a discrete filter, you need to specify a sampling frequency. Then use the bilinear function to convert from continuous to discrete.
My apologies for the delay. Life and software updates intrude.
0 Comments
See Also
Categories
Find more on Filter Design 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!