-
Notifications
You must be signed in to change notification settings - Fork 2
/
NF4.m
49 lines (40 loc) · 1.74 KB
/
NF4.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
42
43
44
45
46
47
48
49
function y = doFilter(x)
%DOFILTER Filters input x and returns output y.
% MATLAB Code
% Generated by MATLAB(R) 9.7 and DSP System Toolbox 9.9.
% Generated on: 02-Apr-2020 12:17:08
%#codegen
% To generate C/C++ code from this function use the codegen command.
% Type 'help codegen' for more information.
persistent Hd;
if isempty(Hd)
% The following code was used to design the filter coefficients:
%
% Fpass1 = 48; % First Passband Frequency
% Fstop1 = 49; % First Stopband Frequency
% Fstop2 = 50; % Second Stopband Frequency
% Fpass2 = 52; % Second Passband Frequency
% Apass1 = 1; % First Passband Ripple (dB)
% Astop = 60; % Stopband Attenuation (dB)
% Apass2 = 1; % Second Passband Ripple (dB)
% Fs = 200; % Sampling Frequency
%
% h = fdesign.bandstop('fp1,fst1,fst2,fp2,ap1,ast,ap2', Fpass1, Fstop1, ...
% Fstop2, Fpass2, Apass1, Astop, Apass2, Fs);
%
% Hd = design(h, 'ellip', ...
% 'MatchExactly', 'stopband', ...
% 'SystemObject', true);
Hd = dsp.BiquadFilter( ...
'Structure', 'Direct form II', ...
'SOSMatrix', [1 0.060139596889612 1 1 0.115515035893294 ...
0.985601347034277; 1 -0.060139596889613 1 1 -0.115515035893295 ...
0.985601347034277; 1 0.0386577726950758 1 1 0.128040582471055 ...
0.926730436294425; 1 -0.038657772695077 1 1 -0.128040582471056 ...
0.926730436294425; 1 -1.22706813782029e-16 1 1 -1.10314996143204e-16 ...
0.798025598466977], ...
'ScaleValues', [0.742075406338059; 0.742075406338059; ...
0.961415246879674; 0.961415246879674; 1.60514559123974; 1]);
end
s = double(x);
y = step(Hd,s);