Tunable Bandpass IIR Filter
Libraries:
DSP System Toolbox /
Filtering /
Filter Sources
Description
Use the Tunable Bandpass IIR Filter block to design an IIR bandpass 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, 3-dB cutoff frequencies, passband ripple, and stopband attenuation while the simulation is running. When the values of these parameters change, the block redesigns the filter and outputs the numerator and denominator coefficients in the fourth-order section form.
Examples
Filter Noisy Signal Using Fourth-Order Section (FOS) Filter in Simulink
Filter a noisy sinusoidal signal using the Fourth-Order Section Filter block. The numerator and denominator coefficients of the fourth-order section filter are obtained using the Tunable Bandpass IIR Filter block. You can tune the frequency specifications of this filter during simulation.
Open and Run the Model
The input signal is a sum of two sine waves with the frequencies of 100 Hz and 350 Hz. The sample rate is 1000 Hz and the number of samples in each frame is 1024. Add zero-mean white Gaussian noise with a variance of 1e-4 to the sum of the sine waves.
The Tunable Bandpass IIR Filter block designs a sixth order bandpass IIR filter with the first and second 3-dB cutoff frequencies at 0.25 rad/sample and 0.75
rad/sample, respectively. Visualize the frequency response of the filter using Filter Visualizer.
Filter the noisy sinusoidal signal using the Fourth-Order Section Filter block. Visualize the original sinusoidal signal and the filtered signal using the Spectrum Analyzer.
Tuning 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 Bandpass IIR Filter block. The filter response updates accordingly.
Change the first 3-dB cutoff frequency to 0.65 rad/sample in the Tunable Bandpass IIR Filter block. The first tone of the sinusoidal signal is attenuated as it no longer falls in the passband frequency of the filter.
Ports
Input
N — Filter order
even positive integer
Specify the filter order as an even positive integer.
Dependency
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 3-dB cutoff frequency
nonnegative scalar ≤ Fc2
Specify the first 3-dB cutoff frequency Fc1 of the filter in normalized frequency units as a nonnegative scalar less than or equal to the second 3-dB cutoff frequency Fc2.
Dependency
To enable this port, select the Specify first 3-dB cutoff frequency from input port parameter.
Data Types: single
| double
Fc2 — Second 3-dB cutoff frequency
Fc1 ≤ positive scalar ≤ 1
Specify the second 3-dB 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
.
Dependency
To enable this port, select the Specify second 3-dB 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.
Dependency
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.
Dependency
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
P-by-5 matrix
Numerator coefficients b, returned as a P-by-5 matrix (fourth-order section form), where P is the number of filter sections.
This equation represents the fourth-order section filter in the transfer function form.
where,
a –– Denominator coefficients matrix. For more details on how to specify this matrix, see the Den output port.
k –– Row index.
The maximum number of filter sections equals
ceil
(Nmax/4), where
Nmax 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 Nmax, the last
ceil
(Nmax/4) −
ceil
(N/4) sections are trivial with
coefficients [b0,
b1,
b2,
b3,
b4] = [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
P-by-5 matrix
Denominator coefficients a, returned as a P-by-5 matrix (fourth-order section form), where P is the number of filter sections.
This equation represents the fourth-order section filter in the transfer function form.
where,
b –– Numerator coefficients matrix. For more details on how to specify this matrix, see the Num output port.
k –– Row index.
The maximum number of filter sections equals
ceil
(Nmax/4), where
Nmax is the value of the
Filter maximum order (must be even) parameter.
The leading denominator coefficient a0 is always 1.
When the actual filter order N is less than the maximum filter
order Nmax, the last
ceil
(Nmax/4) −
ceil
(N/4) sections are trivial with
coefficients [a0,
a1,
a2,
a3,
a4] = [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
Parameters
Design method — Filter design method
Butterworth
(default) | Chebyshev Type I
| Chebyshev Type II
Specify the filter design method as:
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
Dependency
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.
Specify first 3-dB cutoff frequency from input port — Specify first 3-dB cutoff frequency from input port
off
(default) | on
Select this parameter to specify the first 3-dB filter cutoff frequency from the input port Fc1. When you clear this parameter, you can specify the first 3-dB cutoff frequency in the block dialog box using the First 3-dB cutoff frequency parameter.
First 3-dB cutoff frequency — First 3-dB cutoff frequency
0.25
(default) | positive scalar
Specify the first 3-dB cutoff frequency of the filter in normalized frequency units as a positive scalar less than or equal to the second 3-dB cutoff frequency.
Tunable: Yes
Dependency
To enable this parameter, clear the Specify first 3-dB cutoff frequency from input port parameter.
Specify second 3-dB cutoff frequency from input port — Specify second 3-dB cutoff frequency from input port
off
(default) | on
Select this parameter to specify the second 3-dB filter cutoff frequency from the input port Fc2. When you clear this parameter, you can specify the second 3-dB cut-off frequency in the block dialog box using the Second 3-dB cutoff frequency parameter.
Second 3-dB cutoff frequency — Second 3-dB cutoff frequency
0.75
(default) | positive scalar
Specify the second 3-dB cutoff frequency of the filter in normalized frequency units
as a positive scalar greater than or equal to the first 3-dB cutoff frequency and less
than or equal to 1
.
Tunable: Yes
Dependency
To enable this parameter, clear the Specify second 3-dB cutoff frequency from input port parameter.
Specify the passband ripple from input port — 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.
Dependency
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
Dependency
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 — 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.
Dependency
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
Dependency
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 indicates when during the
simulation the block produces the output and updates its internal state. For more
details, see What Is Sample Time? (Simulink).
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 as
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. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time but provides faster simulation speed thanInterpreted execution
.Interpreted execution
–– Simulate model using the MATLAB® interpreter. This option shortens startup time but has slower simulation speed thanCode generation
.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing 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™.
Version History
Introduced in R2023a
See Also
Functions
Blocks
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)