Created
November 30, 2011 21:52
-
-
Save michaelbartnett/1411128 to your computer and use it in GitHub Desktop.
svfilter from last dst lab hw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function svfilter(cutoff, Q) | |
% lowpass | |
[lpf_b, lpf_b] = fir1(10, cutoff, 'low'); | |
% highpass | |
[hpf_b, hpf_b] = fir1(10, cutoff, 'high'); | |
% bandpass | |
% For bandpass coefficients, the order is half of the passed in order parameter (has to be an even order beacuse of poles and zeroes) | |
bw = cutoff / Q; | |
Wn = [cutoff - bw / 2, cutoff + bw / 2]; | |
if (Wn(1) <= 0 || or Wn(2) >= 1) | |
warn('Center frequency and Q problem . . . .'); | |
b_bp = 1; | |
a_bp = 1; | |
else | |
[bpf_b, bpf_b] = fir1(5, cutoff, 'bandpass'); | |
end | |
% display | |
if b_bp == 1 && b_bp == 1 | |
fvtool([lpf_b, lpf_a], [hpf_b, hpf_a]); | |
else | |
fvtool([lpf_b, lpf_a], [hpf_b, hpf_a], [bpf_b, bpf_a]); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment