Tunable Bandstop IIR Filter
Libraries:
DSP System Toolbox /
Filtering /
Filter Sources
Description
Use the Tunable Bandstop IIR Filter block to design a bandstop IIR filter using the Butterworth, Chebyshev Type I and Chebyshev Type II design methods. You can tune the filter design specifications such as the filter order, 3dB cutoff frequencies, passband ripple, and stopband attenuation during simulation. When the values of these parameters change, the block redesigns the filter and outputs the numerator and denominator coefficients in the secondorder section (SOS) form (since R2023b) or the fourthorder section (FOS) form.
Examples
Filter Noisy Signal Using FourthOrder Section (FOS) Filter in Simulink
Filter a noisy sinusoidal signal using the FourthOrder Section Filter block. Obtain the numerator and denominator coefficients of the FOS filter using the Tunable Bandstop IIR Filter block.
Tune the frequency specifications of the FOS filter during simulation.
Open and Run Model
Open the fourthordersection_bandstopfilter.slx
model by clicking the Open Model button.
The input signal in the model is a sum of two sine waves with the frequencies of 200 Hz and 400 Hz. The sample rate is 1000 Hz and the number of samples in each frame is 1024. The Random Source block adds zeromean white Gaussian noise with a variance of 1e4 to the sum of the sine waves.
The Tunable Bandstop IIR Filter block designs a sixthorder bandstop IIR filter with the first and second 3dB cutoff frequencies of 0.2 rad/sample and 0.75 rad/sample, respectively. The block generates coefficients as a cascade of fourthorder sections. Visualize the frequency response of the filter using the Filter Visualizer.
Run the model.
The FourthOrder Section Filter block filters the noisy sinusoidal signal. Visualize the original sinusoidal signal and the filtered signal using the Spectrum Analyzer. The first tone is attenuated as it falls in the stopband region of the filter while the second tone remains unaffected as it falls in the passband region of the filter.
Tune Frequency Specification of FOS Filter
During simulation, you can tune the frequency specifications of the FOS filter by tuning the frequency parameters in the Tunable Bandstop IIR Filter block. The frequency response of the FOS filter updates accordingly.
Change the first 3dB cutoff frequency to 0.5 rad/sample in the Tunable Bandstop IIR Filter block. The first tone of the sinusoidal signal now falls in the passband region and is therefore unttenuated.
Filter Noisy Signal Using SecondOrder Section (SOS) Bandstop Filter in Simulink
Filter a noisy sinusoidal signal using the SecondOrder Section Filter block. Obtain the numerator and denominator coefficients of the SOS filter using the Tunable Bandstop IIR Filter block.
Tune the frequency specifications of the SOS filter during simulation.
Open and Run Model
Open the secondordersection_bandstopfilter
model by clicking the Open Model button.
The input signal in the model is a sum of two sine waves with the frequencies of 200 Hz and 400 Hz. The sample rate is 1000 Hz and the number of samples in each frame is 1024. The Random Source block adds zeromean white Gaussian noise with a variance of 1e4 to the sum of the sine waves.
The Tunable Bandstop IIR Filter block designs a sixthorder bandstop IIR filter with the first and second 3dB cutoff frequencies of 0.2 rad/sample and 0.75 rad/sample, respectively. The block generates coefficients as a cascade of secondorder sections. Visualize the frequency response of the filter using Filter Visualizer.
Run the model.
The SecondOrder Section Filter block filters the noisy sinusoidal signal. Visualize the original sinusoidal signal and the filtered signal using the Spectrum Analyzer. The first tone is attenuated as it falls in the stopband region of the filter while the second tone remains unaffected as it falls in the passband region of the filter.
Tune Frequency Specification of SOS Filter
During simulation, you can tune the frequency specifications of the SOS filter by tuning the frequency parameters in the Tunable Bandstop IIR Filter block. The frequency response of the SOS filter updates accordingly.
Change the first 3dB cutoff frequency to 0.5 rad/sample in the Tunable Bandstop IIR Filter block. The first tone of the sinusoidal signal now falls in the passband region and is therefore unattenuated.
Ports
Input
N — Filter order
even positive integer
Specify the filter order as an even positive integer. You can change the filter order you input through this port during simulation.
Dependencies
To enable this port, select the Specify filter order from input port parameter.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
Fc1 — First 3dB cutoff frequency
nonnegative scalar ≤ Fc2
Specify the first 3dB cutoff frequency Fc1 of the filter in normalized frequency units as a nonnegative scalar less than or equal to the second 3dB cutoff frequency Fc2.
You can change the first 3dB cut off frequency you input through this port during simulation.
Dependencies
To enable this port, select the Specify first 3dB cutoff frequency from input port parameter.
Data Types: single
 double
Fc2 — Second 3dB cutoff frequency
Fc1 ≤ positive scalar ≤ 1
Specify the second 3dB cutoff frequency of the filter in normalized frequency
units as a positive scalar greater than or equal to Fc1 and less
than or equal to 1
.
You can change the second 3dB cut off frequency you input through this port during simulation.
Dependencies
To enable this port, select the Specify second 3dB cutoff frequency from input port parameter.
Data Types: single
 double
Ap — Passband ripple in dB
nonnegative scalar
Specify the passband ripple of the Chebyshev Type I filter as a nonnegative scalar in dB. You can change the passband ripple you input through this port during simulation.
Dependencies
To enable this port:
Set the Design method parameter to
Chebyshev Type I
.Select the Specify the passband ripple from input port parameter.
Data Types: single
 double
Ast — Stopband attenuation in dB
nonnegative scalar
Specify the stopband attenuation of the Chebyshev Type II filter as a nonnegative scalar in dB. You can change the stopband attenuation you input through this port during simulation.
Dependencies
To enable this port:
Set the Design method parameter to
Chebyshev Type II
.Select the Specify the stopband attenuation from input port parameter.
Data Types: single
 double
Output
Num — Numerator coefficients
Pby3 matrix  Pby5 matrix
Numerator coefficients, returned as a Pby3 matrix (SOS form) or a Pby5 matrix (FOS form), where P is the maximum number of filter sections.
SOS form (since R2023b)
When you set Filter cascade sections form to
Secondorder sections
, the block generates a
Pby3 numerator coefficients matrix.
$$b=\left[\begin{array}{ccc}{b}_{01}& {b}_{11}& {b}_{21}\\ {b}_{02}& {b}_{12}& {b}_{22}\\ \vdots & \vdots & \vdots \\ {b}_{0P}& {b}_{1P}& {b}_{2P}\end{array}\right]$$
This equation represents the SOS filter in the transfer function form.
$$H(z)={\displaystyle \prod _{k=1}^{P}{H}_{k}}(z)={\displaystyle \prod _{k=1}^{P}\frac{{b}_{0k}+{b}_{1k}{z}^{1}+{b}_{2k}{z}^{2}}{{a}_{0k}+{a}_{1k}{z}^{1}+{a}_{2k}{z}^{2}}},$$
where
b is a matrix of numerator coefficients.
a is a matrix of denominator coefficients that the block outputs at the Den output port.
k is the row index.
P equals
ceil
(N_{max}/2) in the
SOS form, where N_{max} is the value of the
Filter maximum order (must be even) parameter.
When the actual filter order N is less than the maximum filter
order N_{max}, the last
ceil
(N_{max}/2) −
ceil
(N/2) sections are trivial with
coefficients [b_{0},
b_{1},
b_{2}] = [1, 0, 0].
FOS form
When you set Filter cascade sections form to
Fourthorder sections
, the block generates a
Pby5 numerator coefficients matrix.
$$b=\left[\begin{array}{ccccc}{b}_{01}& {b}_{11}& {b}_{21}& {b}_{31}& {b}_{41}\\ {b}_{02}& {b}_{12}& {b}_{22}& {b}_{32}& {b}_{42}\\ \vdots & \vdots & \vdots & \ddots & \vdots \\ {b}_{0P}& {b}_{1P}& {b}_{2P}& {b}_{3P}& {b}_{4P}\end{array}\right]$$
This equation represents the FOS filter in the transfer function form.
$$H(z)={\displaystyle \prod _{k=1}^{P}{H}_{k}}(z)={\displaystyle \prod _{k=1}^{P}\frac{{b}_{0k}+{b}_{1k}{z}^{1}+{b}_{2k}{z}^{2}+{b}_{3k}{z}^{3}+{b}_{4k}{z}^{4}}{{a}_{0k}+{a}_{1k}{z}^{1}+{a}_{2k}{z}^{2}+{a}_{3k}{z}^{3}+{a}_{4k}{z}^{4}}}$$
P equals
ceil
(N_{max}/4) in the
FOS form.
When the actual filter order N is less than the maximum filter
order N_{max}, the last
ceil
(N_{max}/4) −
ceil
(N/4) sections are trivial with
coefficients [b_{0},
b_{1},
b_{2},
b_{3},
b_{4}] = [1, 0, 0, 0, 0].
The data type of this port depends on the value of the Output data type parameter.
Data Types: single
 double
Den — Denominator coefficients
Pby5 matrix
Denominator coefficients, returned as a Pby3 matrix (SOS form) or a Pby5 matrix (FOS form), where P is the maximum number of filter sections.
SOS form (since R2023b)
When you set Filter cascade sections form to
Secondorder sections
, the block generates a
Pby3 denominator coefficients matrix.
$$a=\left[\begin{array}{ccc}{a}_{01}& {a}_{11}& {a}_{21}\\ {a}_{02}& {a}_{12}& {a}_{22}\\ \vdots & \vdots & \vdots \\ {a}_{0P}& {a}_{1P}& {a}_{2P}\end{array}\right]$$
This equation represents the SOS filter in the transfer function form.
$$H(z)={\displaystyle \prod _{k=1}^{P}{H}_{k}}(z)={\displaystyle \prod _{k=1}^{P}\frac{{b}_{0k}+{b}_{1k}{z}^{1}+{b}_{2k}{z}^{2}}{{a}_{0k}+{a}_{1k}{z}^{1}+{a}_{2k}{z}^{2}}},$$
where
a is a matrix of denominator coefficients and the leading denominator coefficient a_{0} is always 1.
b is a matrix of numerator coefficients that the block outputs at the Num port.
k is the row index.
P equals
ceil
(N_{max}/2) in the
SOS form, where N_{max} is the value of the
Filter maximum order (must be even) parameter.
When the actual filter order N is less than the maximum filter
order N_{max}, the last
ceil
(N_{max}/2) −
ceil
(N/2) sections are trivial with
coefficients [a_{0},
a_{1},
a_{2}] = [1, 0, 0].
FOS form
When you set Filter cascade sections form to
Fourthorder sections
, the block generates a
Pby5 denominator coefficients matrix.
$$a=\left[\begin{array}{ccccc}{a}_{01}& {a}_{11}& {a}_{21}& {a}_{31}& {a}_{41}\\ {a}_{02}& {a}_{12}& {a}_{22}& {a}_{32}& {a}_{42}\\ \vdots & \vdots & \vdots & \ddots & \vdots \\ {a}_{0P}& {a}_{1P}& {a}_{2P}& {a}_{3P}& {a}_{4P}\end{array}\right]$$
This equation represents the FOS filter in the transfer function form.
$$H(z)={\displaystyle \prod _{k=1}^{P}{H}_{k}}(z)={\displaystyle \prod _{k=1}^{P}\frac{{b}_{0k}+{b}_{1k}{z}^{1}+{b}_{2k}{z}^{2}+{b}_{3k}{z}^{3}+{b}_{4k}{z}^{4}}{{a}_{0k}+{a}_{1k}{z}^{1}+{a}_{2k}{z}^{2}+{a}_{3k}{z}^{3}+{a}_{4k}{z}^{4}}}$$
P equals
ceil
(N_{max}/4) in the
FOS form.
The leading denominator coefficient a_{0} is always 1.
When the actual filter order N is less than the maximum filter
order N_{max}, the last
ceil
(N_{max}/4) −
ceil
(N/4) sections are trivial with
coefficients [a_{0},
a_{1},
a_{2},
a_{3},
a_{4}] = [1, 0, 0, 0, 0].
The data type of this port depends on the value of the Output data type parameter.
Data Types: single
 double
g — Scale values for each secondorder section
vector
Since R2023b
Scale values for each secondorder section, returned as a vector with
P + 1 elements, where P is the maximum number
of filter sections and equals
ceil
(N_{max}/2), where
N_{max} is the value of the
Filter maximum order (must be even) parameter.
Tunable: Yes
Dependencies
To enable this port:
Set Filter cascade sections form to
Secondorder sections
.Select the Design has scale values parameter.
Data Types: single
 double
Parameters
Design method — Filter design method
Butterworth
(default)  Chebyshev Type I
 Chebyshev Type II
Specify the filter design method as one of these:
Butterworth
Chebyshev Type I
Chebyshev Type II
Specify filter order from input port — Flag to specify filter order from input port
off
(default)  on
Select this parameter to specify the filter order from the input port N. When you clear this parameter, you can specify the filter order in the block dialog box using the Filter order (must be even) parameter.
Filter order (must be even) — Filter order
6
(default)  even positive integer
Specify the filter order as an even positive integer less than or equal to the value of the Filter maximum order (must be even) parameter.
Tunable: Yes
Dependencies
To enable this parameter, clear the Specify filter order from input port parameter.
Filter maximum order (must be even) — Maximum order of filter
10
(default)  even positive integer
Specify the maximum order of the filter as an even positive integer. The value you specify in the Filter order (must be even) parameter must be less than or equal to the value you specify in the Filter maximum order (must be even) parameter.
Design has scale values — Specify if filter has scale values for each section
off
(default)  on
Since R2023b
Specify if the filter has scale values for each section. When you select this parameter, the block outputs the scale values through the g output port.
Dependencies
To enable this parameter, set Filter cascade sections form to
Secondorder sections
.
Specify first 3dB cutoff frequency from input port — Flag to specify first 3dB cutoff frequency from input port
off
(default)  on
Select this parameter to specify the first 3dB filter cutoff frequency from the input port Fc1. When you clear this parameter, you can specify the first 3dB cutoff frequency in the block dialog box using the First 3dB cutoff frequency parameter.
First 3dB cutoff frequency — First 3dB cutoff frequency
0.25
(default)  positive scalar
Specify the first 3dB cutoff frequency of the filter in normalized frequency units as a positive scalar less than or equal to the second 3dB cutoff frequency.
Tunable: Yes
Dependencies
To enable this parameter, clear the Specify first 3dB cutoff frequency from input port parameter.
Specify second 3dB cutoff frequency from input port — Flag to specify second 3dB cutoff frequency from input port
off
(default)  on
Select this parameter to specify the second 3dB filter cutoff frequency from the input port Fc2. When you clear this parameter, you can specify the second 3dB cutoff frequency in the block dialog box using the Second 3dB cutoff frequency parameter.
Second 3dB cutoff frequency — Second 3dB cutoff frequency
0.75
(default)  positive scalar
Specify the second 3dB cutoff frequency of the filter in normalized frequency units
as a positive scalar greater than or equal to the first 3dB cutoff frequency and less
than or equal to 1
.
Tunable: Yes
Dependencies
To enable this parameter, clear the Specify second 3dB cutoff frequency from input port parameter.
Specify the passband ripple from input port — Flag to specify passband ripple from input port
off
(default)  on
Select this parameter to specify passband ripple from the input port Ap. When you clear this parameter, you can specify the passband ripple in the block dialog box using the Passband ripple (dB) parameter.
Dependencies
To enable this parameter, set the Design method parameter to
Chebyshev Type I
.
Passband ripple (dB) — Passband ripple in dB
1
(default)  positive scalar
Specify the passband ripple of the Chebyshev Type I filter as a positive scalar in dB.
Tunable: Yes
Dependencies
To enable this parameter:
Set the Design method parameter to
Chebyshev Type I
.Clear the Specify the passband ripple from input port parameter.
Specify the stopband attenuation from input port — Flag to specify stopband attenuation from input port
off
(default)  on
Select this parameter to specify stopband attenuation from the input port Ast. When you clear this parameter, you can specify the stopband attenuation in the block dialog box using the Stopband attenuation (dB) parameter.
Dependencies
To enable this parameter, set the Design method parameter to
Chebyshev Type II
.
Stopband attenuation (dB) — Stopband attenuation in dB
60
(default)  positive scalar
Specify the stopband attenuation of the Chebyshev Type II filter as a positive scalar in dB.
Tunable: Yes
Dependencies
To enable this parameter:
Set the Design method parameter to
Chebyshev Type II
.Clear the Specify the stopband attenuation from input port parameter.
Sample time — Sample time in seconds
1
(default)  positive scalar  Inf
Specify the sample time as 1
(inherited), Inf
(constant sample time), or a positive scalar. This parameter determines when the block
produces the output and updates its internal state during simulation. For more details,
see What Is Sample Time? (Simulink).
Filter cascade sections form — Form of filter cascade sections
Fourthorder sections
(default)  Secondorder sections
Since R2023b
Specify the form of the filter cascade sections as one of these:
Fourthorder sections
–– The block generates a Pby5 matrix of filter coefficients.Secondorder sections
–– The block generates a Pby3 matrix of filter coefficients.
Output data type — Data type of filter coefficients
double
(default)  single
Specify the data type of the filter coefficients that the block outputs through the
Num and Den ports. You can set the data type
to double
or single
.
Simulate using — Type of simulation to run
Code generation
(default)  Interpreted execution
Specify the type of simulation to run as one of the following:
Code generation
–– Simulate model using generated C code. The first time you run a simulation, Simulink^{®} generates C code for the block. Simulink reuses the C code in subsequent simulations as long as the model does not change. This option requires additional startup time but subsequent simulations are faster compared toInterpreted execution
.Interpreted execution
–– Simulate model using the MATLAB^{®} interpreter. This option shortens startup time but subsequent simulations are slower compared toCode generation
.
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

References
[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Prentice Hall, 1996.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
When you generate code from this block, you can tune the filter design specifications in the generated code.
Version History
Introduced in R2023aR2023b: Tunable Bandstop IIR Filter block generates coefficients in secondorder section form
Starting in R2023b, the Tunable Bandstop IIR Filter block generates filter coefficients in the SOS or FOS form. You can specify the form using the new Filter cascade sections form parameter.
When you set Filter cascade sections form to Secondorder
sections
and select Design has scale values, the block
outputs scale values through the g port.
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)