主要内容

firgr

Parks-McClellan FIR filter

Syntax

b = firgr(n,f,a,w)
b = firgr(n,f,a,'hilbert')
b = firgr(m,f,a,r),
b = firgr({m,ni},f,a,r)
b = firgr(n,f,a,w,e)
b = firgr(n,f,a,s)
b = firgr(n,f,a,s,w,e)
b = firgr(...,'1')
b = firgr(...,'minphase')
b = firgr(..., 'check')
b = firgr(...,{lgrid}),
[b,err] = firgr(...)
[b,err,res] = firgr(...)
b = firgr (n、f、fresp w)
b = firgr(n,f,{fresp,p1,p2,...},w)
b = firgr(n,f,a,w)

描述

firgris a minimax filter design algorithm you use to design the following types of real FIR filters:

  • Types 1-4 linear phase:

    • 1型甚至是顺序,对称

    • Type 2 is odd order, symmetric

    • Type 3 is even order, antisymmetric

    • Type 4 is odd order, antisymmetric

  • Minimum phase

  • Maximum phase

  • 最低订单(甚至是奇数)

  • 额外的涟漪

  • Maximal ripple

  • Constrained ripple

  • 单点频带(排名和峰值)

  • Forced gain

  • Arbitrary shape frequency response curve filters

b = firgr(n,f,a,w)returns a lengthn+1线性相位FIR滤波器具有最佳的近似值fanda从minimax意义上讲。wis a vector of weights, one per band. When you omitw, all bands are weighted equally. For more information on the input arguments, refer toFIRPMinSignal Processing Toolbox™ User's Guide

b = firgr(n,f,a,'hilbert')andb=firgr(n,f,a,'differentiator')design FIR Hilbert transformers and differentiators. For more information on designing these filters, refer toFIRPMinSignal Processing Toolbox User's Guide

b = firgr(m,f,a,r),wheremis one of '最低订购','mineven' or 'minodd', designs filters repeatedly until the minimum order filter, as specified inm, that meets the specifications is found.ris a vector containing the peak ripple per frequency band. You must specifyr。When you specify 'mineven' or 'minodd', the minimum even or odd order filter is found.

b = firgr({m,ni},f,a,r)wheremis one of '最低订购','mineven' or 'minodd', usesnias the initial estimate of the filter order.niis optional for common filter designs, but it must be specified for designs in whichFIRPMordcannot be used, such as while designing differentiators or Hilbert transformers.

b = firgr(n,f,a,w,e)specifies independent approximation errors for different bands. Use this syntax to design extra ripple or maximal ripple filters. These filters have interesting properties such as having the minimum transition width.e是一个单元阵列特征向量指定the approximation errors to use. Its length must equal the number of bands. Entries ofemust be in the form 'e#' 在哪里#指示用于相应频段的近似误差。例如,当e = {'e1','e2','e1'}, the first and third bands use the same approximation error'e1'and the second band uses a different one'e2'。Note that when all bands use the same approximation error, such as{'e1','e1','e1',...}, it is equivalent to omittinge, as inb = firgr(n,f,a,w)

b = firgr(n,f,a,s)is used to design filters with special properties at certain frequency points.sis a cell array of character vectors and must be the same length asfanda。条目smust be one of:

  • 'n'— normal frequency point.

  • 's'— single-point band. The frequency “band” is given by a single point. The corresponding gain at this frequency point must be specified ina

  • 'f'— forced frequency point. Forces the gain at the specified frequency band to be the value specified.

  • '一世'— indeterminate frequency point. Use this argument when adjacent bands abut one another (no transition region).

例如,以下命令设计一个带有零价值的单点停止频段(置换)为0.25和0.55的频带滤波器。

b = firgr(42,[0 0.2 0.25 0.3 0.5 0.55 0.6 1],... [1 1 0 1 1 1 0 1 1],{'n n'n'n's''n'n'n''n'n's''n''n'})

b = firgr(82,[0 0.055 0.06 0.1 0.15 1],[0 0 0 0 1 1],...{'n' 'i' 'f' 'n' 'n' 'n'})designs a highpass filter with the gain at 0.06 forced to be zero. The band edge at 0.055 is indeterminate since the first two bands actually touch. The other band edges are normal.

b = firgr(n,f,a,s,w,e)specifies weights and independent approximation errors for filters with special properties. The weights and properties are included in vectorswande。Sometimes, you may need to use independent approximation errors to get designs with forced values to converge. For example,

b = 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 = firgr(...,'1')设计一个1型滤波器(均匀的对称)。您可以指定2型(奇数对称),类型3(偶数反对称)和4型(奇数反对称)过滤器。请注意,限制适用于a在F = 0或F = 1时,FIR滤波器类型2、3和4。

b = firgr(...,'minphase')designs a minimum-phase FIR filter. You can use the argument'maxphase'设计最大的相位FIR滤波器。

b = firgr(..., 'check')returns a warning when there are potential transition-region anomalies.

b = firgr(...,{lgrid}),where{lgrid}is a scalar cell array. The value of the scalar controls the density of the frequency grid by setting the number of samples used along the frequency axis.

[b,err] = firgr(...)returns the unweighted approximation error magnitudes.errcontains one element for each independent approximation error returned by the function.

[b,err,res] = firgr(...)returns the structurerescomprising optional results computed byfirgrrescontains the following fields.

Structure Field

Contents

res.fgrid

Vector containing the frequency grid used in the filter design optimization

res.des

Desired response onfgrid

res.wt

权重fgrid

res.h

Actual frequency response on the frequency grid

res.error

Error at each point (desired response - actual response) on the frequency grid

res.iextr

Vector of indices intofgridof external frequencies

res.fextr

Vector of external frequencies

res.order

Filter order

res.edgecheck

Transition-region anomaly check. One element per band edge. Element values have the following meanings: 1 = OK, 0 = probable transition-region anomaly, -1 = edge not checked. Computed when you specify the'check'函数语法中的输入选项。

res.iterations

Number ofs优化的迭代

res.evals

数量的函数evaluations for the optimization

firgris also a “function function,” allowing you to write a function that defines the desired frequency response.

b = firgr (n、f、fresp w)returns a length N + 1 FIR filter which has the best approximation to the desired frequency response as returned by the user-defined functionfresp。Use the followingfirgrsyntax to callfresp:

[DH,DW] = fresp(n,f,gf,w)

where:

  • frespidentifies the function that you use to define your desired filter frequency response.

  • n是过滤顺序。

  • fis the vector of frequency band edges which must appear monotonically between 0 and 1, where 1 is one-half of the sampling frequency. The frequency bands spanf(k)tof(k+1)forkodd. The intervalsf(k+1)tof(k+2)forkodd are “transition bands” or “don't care” regions during optimization.

  • gfis a vector of grid points that have been chosen over each specified frequency band byfirgr,并确定频率firgrevaluates the response function.

  • w是在优化期间使用的真实,正权重的向量,一个供应。wis optional in the call tofirgr。如果您不指定w, it is set to unity weighting before being passed tofresp

  • dhanddware the desired frequency response and optimization weight vectors, evaluated at each frequency in gridgf

firgrincludes a predefined frequency response function named'FIRPMFRF2'。您可以根据更简单的'FIRPMFRF'。看到帮助private/firpmfrffor more information.

b = firgr(n,f,{fresp,p1,p2,...},w)specifies optional argumentsp1,p2,...,,pn传递到响应功能fresp

b = firgr(n,f,a,w)is a synonym forb = firgr(n,f,{'firpmfrf2',a},w), 在哪里ais a vector containing your specified response amplitudes at each band edge inf。By default,firgrdesigns symmetric (even) FIR filters.'FIRPMFRF2'is the predefined frequency response function. If you do not specify your own frequency response function (thefrespvariable),firgruses 'FIRPMfrf2'

b = firgr(...,'h')andb = firgr(...,'d')design antisymmetric (odd) filters. When you omit the'H'or'd'arguments from thefirgrcommand syntax, each frequency response functionfrespcan tellfirgrto design either an even or odd filter. Use the command syntaxsym =fresp('defaults',{n,f,[],w,p1,p2,...})

firgrexpectsfrespto returnsym ='偶'orsym ='odd'。Iffrespdoes not support this call,firgrassumes even symmetry.

有关输入参数的更多信息firgr, refer toFIRPM

例子

collapse all

Design an FIR filter with two single-band notches at 0.25 and 0.55.

b1 = 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'});

Design a highpass filter whose gain at 0.06 is forced to be zero. The gain at 0.055 is indeterminate since it should abut the band.

b2 = firgr(82,[0 0.055 0.06 0.1 0.15 1],[0 0 0 0 1 1],。。。{'n''一世''f''n''n''n'});

Design a second highpass filter with forced values and independent approximation errors.

b3 = firgr(82,[0 0.055 0.06 0.1 0.15 1], [0 0 0 0 1 1],。。。{'n''一世''f''n''n''n'}, [10 1 1] ,{'e1''e2''e3'});

Use the filter visualization tool to view the results of the filters.

hvft = fvtool(b1,1,b2,1,b3,1); legend(hvft,'Filter b1','Filter b2','Filter b3')

Figure Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 3 objects of type line. These objects represent Filter b1, Filter b2, Filter b3.

参考

Shpak, D.J. and A. Antoniou, “A generalized Remez method for the design of FIR digital filters,”IEEE®Trans. Circuits and Systems, pp. 161-174, Feb. 1990.

Extended Capabilities

Version History

Introduced in R2011a