fir2
|
Page in progress. |
Calculation of FIR filter coefficients based on frequency sampling.
| Library |
|
Syntax
Function call
-
b = fir2(n,f,m)— returns the FIR filtern-th order with frequency-amplitude characteristics given by vectorsfandm. The function linearly interpolates the desired frequency response onto a dense grid, and then uses the inverse Fourier transform and the Hamming window to obtain the filter coefficients.
Use the function fir1 for standard window low-pass filter, bandpass filter, high-pass filter, notch filter and multiband filter.
|
Arguments
Input arguments
# n — filter order
+
integer scalar
Details
The filter order is set as a positive integer.
For configurations with Nyquist frequency bandwidth, the function fir2 always uses an even order. If an odd value is specified for one of these configurations n, function fir2 increases n on 1.
| Data types |
|
# f — frequency-amplitude response
+
vector
Details
The frequency-amplitude characteristic, defined as a vector of the same length as m.
Argument f — a vector of frequency points in the range from 0 before 1, where 1 corresponds to the Nyquist frequency. The first point of the vector f must be equal to 0, and the last one — 1. Vector elements f they must be sorted in ascending order. Repeated frequency points are allowed and are considered as steps in the frequency response.
| Data types |
|
# lap is the length of the area around the duplicate frequency points
+
25 (by default) | a positive integer scalar
Details
The length of the area around the duplicate frequency points, set as a positive integer.
| Data types |
|
# window — window
+
column vector
Details
A window defined as a column vector. The window vector must contain n + 1 element. If the argument is window if not specified, then the function fir2 uses the Hamming window.
Function fir2 does not automatically increase the length of the argument window when trying to design an odd-order filter with a Nyquist frequency bandwidth.
| Data types |
|
Algorithms
Function fir2 uses frequency sampling to calculate the filter coefficients. The function linearly interpolates the desired frequency response into a dense, evenly distributed length grid npt. Function fir2 it also creates point areas lap around duplicate values f to ensure steep but smooth transitions. To obtain the filter coefficients, the function applies the inverse fast Fourier transform to the grid and multiplies by the argument window.