firls
|
Page in progress. |
Calculation of the coefficients of a linear phase response FIR filter using the least squares method.
| Library |
|
Arguments
Input arguments
# n — filter order
+
real positive scalar
Details
The filter order is set as a real positive number.
# f — normalized frequency values
+
real-valued vector
Details
Normalized frequency values, set as a vector of real numbers. The argument must be in the range [0,1], where 1 corresponds to the Nyquist frequency. The number of elements of a vector is always a multiple 2. The frequencies should be arranged in non-decreasing order.
# a — required amplitude
+
vector
Details
Required amplitudes at the points specified in f, are specified as a vector. Length f and a it must be the same. The length must be an even number.
-
Required amplitude at frequencies between pairs of points for odd numbers — this is a straight line segment connecting the points and .
-
Required amplitude at frequencies between pairs of points with an even number not defined. The areas between such points are transition areas or areas that are not relevant for a particular application.
# ftype — filter type
+
"hilbert" | "differentiator"
Details
The filter type for linear phase characteristic filters with odd symmetry (type III and type IV), defined as "hilbert" or "differentiator":
-
"hilbert"— output coefficients inbthey obey the ratio , . This class of filters includes the Hilbert converter, whose specified amplitude is1in the entire bandwidth. -
"differentiator"— for bands with non-zero amplitude, the filter weighs the error by a factor of , so the error at low frequencies is significantly less than at high frequencies. For FIR differentiators, the amplitude characteristic of which is proportional to the frequency, these filters minimize the maximum relative error (the maximum value of the ratio of error to a given amplitude).
Algorithms
Function firls designs a FIR filter with a linear phase response that minimizes the weighted integral square error between the ideal piecewise linear function and the amplitude-frequency response of the filter in a given frequency range.
The book [2] describes the theoretical approach underlying the function firls. The function solves a system of linear equations using the operator \in Engee. For the order filter the solution of the system of equations involves a square matrix of the scalar product of the size , where When odd, and When even number.
Input arguments and the frequency-amplitude characteristics of the filter are set:
-
— a vector of pairs of frequency values set in the range from
0before1, where1corresponds to the Nyquist frequency. The frequencies should be arranged in ascending order. You can specify duplicate frequency values. -
— a vector containing the required amplitudes at the points specified in the vector .
Required amplitude function at frequencies between pairs of points for odd numbers — this is a straight line segment connecting the points and .
Required amplitude function at frequencies between pairs of points with an even number not defined. These are transitional ("unimportant") areas.
-
and they have the same length. This length must be an even number.
Function firls designs filters with linear phase characteristics of type I, II, III and IV. Filters of type I and II are used by default for even and odd numbers. accordingly, while the flags "hilbert" and "differentiator" create type III filters ( even) and IV ( odd). Different types of filters have different symmetries and limitations on frequency characteristics (for more information, see [1]).
| Filter type with linear phase response | Filter order | Symmetry of coefficients | Response H(f), f = 0 | Response H(f), f = 1 (Nyquist) |
|---|---|---|---|---|
Type I |
Even-numbered |
|
There are no restrictions |
There are no restrictions |
Type II |
Odd |
|
There are no restrictions |
|
Type III |
Even-numbered |
|
|
|
Type IV |
Odd |
|
|
There are no restrictions |