fir1
|
Page in progress. |
Calculation of FIR filter coefficients using different windows.
| Library |
|
Syntax
Arguments
Input arguments
# n — filter order
+
scalar
Details
The filter order is set as a positive integer.
For high-pass filters and notch filters, the function fir1 always uses an even filter order. The order must be even, since symmetric FIR filters of odd order must have zero gain at the Nyquist frequency. If an odd value is specified for the high-pass filter or the blocking filter n, then the function fir1 increases n on 1.
| Data types |
|
# Wn is the cutoff frequency
+
scalar | two-element vector | multi-element vector
Details
The cutoff frequency, specified as a scalar, two-element vector, or multi-element vector.
All the elements Wn must be in the range of 0 before 1, where 1 corresponds to the Nyquist frequency. The Nyquist frequency is equal to half the sampling frequency, or rad/countdown.
-
If
Wnis a scalar, then the functionfir1designs a low-pass or high-pass filter with a cutoff frequencyWn. The cutoff frequency is the frequency at which the gear ratio is-6dB. -
If
Wn— two-element vector[W1 W2], whereW1<W2Thenfir1designs a bandpass or notch filter with a lower cutoff frequencyW1and the upper cutoff frequencyW2. -
If
Wn— multi-element vector[W1 W2 … Wn], whereW1<W2< … <WnThenfir1designs a multiband filtern-th order with stripes0< <W1,W1< <W2,…,Wn< <1.
| Data types |
|
# window — window
+
vector
Details
A vector for windowing the impulse response. The window vector must contain n + 1 element. The default function is fir1 uses the Hamming window. List of available windows:
-
"bartlett"— Bartlett’s window; -
"blackman"— Blackman’s window;
-
"chebyshev"— Chebyshev’s window;
-
"hamming"— Hamming window; -
"hann"— Hannah’s window; -
"kaiser"— Kaiser’s window;
-
"triangular"— triangular window;
Optional parameters can be specified for Kaiser and Chebyshev windows. Examples:
Using the Kaiser window with the parameter beta = 4.0:
b = fir1(N, Wn, window("kaiser", N+1, 4.0))
Using the Chebyshev window with 65.0 dB relative attenuation of the side lobes:
b = fir1(N, Wn, window("chebyshev", N+1, 65.0), "high")
| Data types |
|
# ftype — filter type
+
"low" | "high" | "bandpass" | "stop" | "DC-0" | "DC-1"
Details
Filter Type:
-
"low"defines a low-pass filter with a cutoff frequencyWn,"low"— the default value for a scalar functionWn. -
"high"defines a high-pass filter with a cutoff frequencyWn. -
"bandpass"defines a bandpass filter ifWn— two-element vector,"bandpass"— default value ifWnIt consists of two elements. -
"stop"detects the notch filter ifWn— a two-element vector. -
"DC-0"determines that the first band of the multiband filter is a delay band,"DC-0"— default value ifWnIt consists of more than two elements. -
"DC-1"determines that the first band of the multiband filter is the bandwidth.
# scaleopt — scaling the filter
+
"scale" (by default) | "noscale"
Details
Scaling the filter:
-
"scale"scales the coefficients so that the amplitude-frequency response of the filter in the center of the bandwidth is equal to1(0dB). -
"noscale"does not scale coefficients.
Algorithms
Function fir1 uses the least squares approximation to calculate the filter coefficients, and then smooths the impulse response using window.