-
Notifications
You must be signed in to change notification settings - Fork 10
/
bpmin.m
42 lines (36 loc) · 981 Bytes
/
bpmin.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function epb=bpmin(H,F,dB)
% epb=BPMIN(H,F,dB)
%
% Takes a filter, figures out where its gain drops below a certain frequency
%
% INPUT:
%
% H Squared magnitude response (in DECIBEL)
% F Frequency vector
% dB Stopband level (positive)
%
% OUTPUT:
%
% epb Frequencies where the pass band exceeds dB level
%
% SEE ALSO:
%
% BANDPASS, DECIBEL
%
% Tested on MATLAB Version: 9.0.0.341360 (R2016a)
%
% Last modified by fjsimons-at-alum.mit.edu, 02/18/2020
% Supply defaults
defval('dB',3)
% Make the points that you look for zero
H=H+dB;
% Find the single maximum so you can split the search
Hm=find(H==max(H));
% Both are now monotonic functions
% I used to go from 1 but then it hits -Inf so now I go from 2
F1=interp1(H(2:Hm),F(2:Hm),0);
% I used to go from Hm+1 but then finite-precision sometimes ruins it
% so take our chances that this will remove the issue
F2=interp1(H(Hm+length(F)/20:end),F(Hm+length(F)/20:end),0);
% The two requested points
epb=[F1 F2];