firgr
Designing a generalized FIR Remez filter.
| Library |
|
Syntax
Function call
-
b,err,res = firgr(n,f,a,w)— uses a minimax algorithm to design a real linear-phase FIR filter with a vector of coefficientsblengthn + 1. In the sense of the minimax criterion, the filter provides the best approximation to the desired frequency response, determined by the parametersfanda. Argumentw— a vector of filter weights, one for each band. If not usedw, all bands will be weighted equally. The function also returns the values of the unweighted approximation errors.errand the structureres, containing additional results calculated usingfirgr. For more information about the arguments, seefirpm.
-
b,err,res = firgr(m,f,a,r)— re-designs filters until a filter of the minimum order specified in is found.mand corresponding to the argumentsfanda. ArgumentmIt can take one of the values:"minorder","mineven"or"minodd". Argumentr— this is a vector containing the peak ripple for each frequency band, it must be set. When specifying"mineven"or"minodd"the function finds the minimum even or odd order filter.
-
b,err,res = firgr((m,ni),f,a,r)— as an initial estimate of the filter order, the following is usedni. ArgumentniIt is not mandatory for standard filter designs, but it must be specified for designs in which it is impossible to usefirpmordfor example, when designing differentiators or Hilbert converters.
-
b,err,res = firgr(n,f,a,w,e)— sets independent approximation errors for different bands. Use this syntax to design filters with additional ripple or maximum ripple. These filters have interesting properties, such as the minimum width of the transition. Argumente— this is a string vector specifying the approximation errors that should be used. Its length should be equal to the number of stripes.
-
b,err,res = firgr(n,f,a,s,w,e)— sets the filter weights and independent approximation errors for filters with special properties. The weights and properties are contained in the vectorswande. Sometimes it may be necessary to use independent approximation errors to ensure that the design converges with the specified values. For example,b,err,res = firgr(82,[0 0.055 0.06 0.1 0.15 1], [0 0 0 0 1 1],['n' 'i' 'f' 'n' 'n' 'n'], [10 1 1] ,["e1" "e2" "e3"]);
-
b,err,res = firgr(_,type) — designs a filter, the type of which is specified in the argumenttype. Argumenttypeset as"1"— symmetric even-order filter,"2"— symmetric odd-order filter,"3"— antisymmetric filter of even order or"4"— antisymmetric filter of odd order. Note that for FIR filters of the following types:"2","3"and"4"there are limitations on the amplitude valuesa. For type filters"2"and"3"the amplitude should be equal to0on the frequenciesf = 0andf = 1, and for a filter like"4"the amplitude should be equal to0on the frequencyf = 0.
Arguments
Input arguments
# n — filter order
+
scalar
Details
The filter order, specified as an integer, is at least 3.
| Типы данных |
|
# f — normalized frequencies
+
vector
Details
Normalized frequency points, defined as a vector of real values. The value of the argument must be in the range [0, 1], where 1 corresponds to the Nyquist frequency. Vector length f it must be even. The frequencies should be ordered in ascending order.
| Типы данных |
|
# w — approximation coefficients within the frequency bands
+
vector
# ftype — filter type
+
"hilbert" | "differentiator"
Details
The filter type for linear-phase filters with odd symmetry (type III and type IV), set by one of the following values:
-
"hilbert"— coefficients at the output inbthey obey the ratio . This class of filters includes the Hilbert converter, which has a specified amplitude equal to1, in the entire frequency band.For example,
b = firgr(30,[0.1 0.9],[1 1],"hilbert");designs an approximate Hilbert FIR converter of length
31. -
"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 the error to the desired amplitude).
| Типы данных |
|
# m is the type of setting the minimum filter order
+
"minorder" | "mineven" | "minodd"
Details
The type of setting the minimum filter order, set as "minorder", "mineven" or "minodd". When specifying "mineven" or "minodd" The function designs a minimum even or minimum odd order filter.
| Типы данных |
|
# type — the number of the filter type
+
"1" | "2" | "3" | "4"
Details
The filter type specified by one of the following values:
-
"1"— symmetric even-order filter; -
"2"— symmetric odd-order filter; -
"3"— antisymmetric filter of even order; -
"4"— antisymmetric filter of odd order.
| Типы данных |
|
# mp — choose between minimum or maximum phase filter
+
"minphase" | "maxphase"
Details
Choosing between a filter with a minimum "minphase" or the maximum "maxphase" the phase.
| Типы данных |
|
# ni is the initial estimate of the filter order
+
scalar
Details
The initial estimate of the filter order, set as an integer greater than or equal to 3. The function takes this value in the syntax b = firgr((m,ni),f,a,r). Argument ni It is not mandatory for typical filter designs, but it must be specified for designs in which it is impossible to use firpmord for example, when designing differentiators or Hilbert converters.
| Типы данных |
|
# e — independent approximation errors for frequency bands
+
vector | the tuple
Details
Independent approximation errors used for different bands, specified as a string vector or tuple. Length e it must be equal to the number of lanes. Elements e must have the form "e#", where # specifies which approximation error should be used for the corresponding band. For example, when e = ["e1","e2","e1"] the first and third bands use the same approximation error "e1", and the second lane is the other one "e2". When all bands use the same approximation error, for example ["e1","e1","e1",…], this is equivalent to skipping e as in the syntax b,err,res = firgr(n,f,a,w).
| Типы данных |
|
# s — specification of frequency points
+
vector | the tuple
Details
Special properties at certain points of the frequency, specified as a vector or tuple of symbols. Argument s must have the same length as f and a. Elements s must have one of the following values:
-
'n'— the usual frequency point. -
's'— single-point strip. Frequency «stripe» It is defined by a single point. Specify the appropriate gain at this frequency point ina. -
'f'— forced frequency point. Forcibly sets the gain in the specified frequency band to the set value. -
'i'— an undefined frequency point. Use this value when adjacent frequency bands are adjacent to each other (without a transition zone).
For example, the following team designs a barrier filter with single-point delay bands (recesses) with a zero value at frequencies 0.25 and 0.55.
b,err,res = firgr(42,[0 0.2 0.25 0.3 0.5 0.55 0.6 1], [1 1 0 1 1 0 1 1],['n' 'n' 's' 'n' 'n' 's' 'n' 'n'])
And this team is designing a high-pass filter with a gain factor that is forcibly set to zero at the point 0.06. The edge of the strip at the point 0.055 it is indeterminate because the first two lanes actually touch. The remaining edges of the stripes are normal.
b,err,res = firgr(82,[0 0.055 0.06 0.1 0.15 1],[0 0 0 0 1 1],['n' 'i' 'f' 'n' 'n' 'n'])
| Типы данных |
|
# lgrid — frequency grid density
+
the tuple
Details
Controls the density of the frequency grid, which has approximately (lgrid*n)/(2*bw) frequency points where bw — the share of the total frequency band interval [0, 1], covered by f. The higher the value is lgrid the more precisely the filter approaches the reference filter with uniform pulsations, but such calculations take longer. Default value 16 — this is the minimum value that should be set for lgrid.
| Типы данных |
|
# hd — filter parity
+
"h" | "d" | 'h' | 'd'
Details
The parity of the filter, set as "h", "d", 'h' or 'd'.
| Типы данных |
|
Output arguments
# b — filter coefficients
+
vector
Details
Filter coefficients returned as a vector of length n + 1.
Function firgr uses a minimax design algorithm for the following types of real FIR filters:
-
Types 1-4 with linear phase:
-
Type 1 — even order, symmetric;
-
Type 2 — odd order, symmetrical;
-
Type 3 — even order, antisymmetric;
-
Type 4 is of odd order, antisymmetric.
-
-
The minimum phase.
-
The maximum phase.
-
Minimum order (even or odd).
-
Additional ripple.
-
Maximum ripple.
-
Ripple with limitations.
-
Single-point strip (with notch and peak).
-
Forced reinforcement.
# err is the value of the unweighted approximation error
+
scalar | vector
Details
The values of the unweighted approximation errors returned as a scalar or vector. Array err contains one element for each independent approximation error returned by the function.
# res — frequency response
+
structure
Details
The frequency response returned as a structure. Structure res contains the following fields:
| Structure Field | Content |
|---|---|
|
A vector containing the frequency grid used to optimize the filter design. |
|
The desired response to |
|
Weight factors |
|
The actual frequency characteristics on the frequency grid. |
|
Error at each point (desired characteristic — actual characteristic) on the frequency grid. |
|
The index vector in |
|
The vector of external frequencies. |
|
The filter order. |
|
Checking for anomalies in the transition zone. One element for each edge of the strip. The elements have the following values: |
|
Number of iterations |
|
The number of calculations of the function for optimization. |