mafan88的个人空间 https://blog.eetop.cn/162539 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

fir filter

已有 2926 次阅读| 2011-9-19 18:44 |个人分类:数字信号处理

译)FIR filter  

2011-05-17 14:32:26|  分类: 默认分类 |字号 订阅

FIR Method

FIR Method

Corresponding Function

Comment

Equiripple

firpm

available for all response types, except Raised Cosine.

Least-squares

firls

available for all response types, except Raised Cosine.

Window

fir1

available for the Lowpass, Raised Cosine, Highpass, Bandpass, and Bandstop response types only

Constr. least- squares

fircls

available for the Lowpass, Raised Cosine, Highpass, Bandpass, and Bandstop response types only

Complex Equiripple

cfirpm

available for the Lowpass, Raised Cosine, Highpass, and Multiband response types only

Maximally flat

maxflat

available for Lowpass response type only

 

 

1.      firpm

          Parks-McClellan optimal FIR filter design


Syntax
b = firpm(n,f,a)
b = firpm(n,f,a,w)
b = firpm(n,f,a, 'ftype')
b = firpm(n,f,a,w, 'ftype')
b = firpm(...,{lgrid})
[b,err] = firpm(...)
[b,err,res] = firpm(...)
b = firpm(n,f,@fresp,w)
b = firpm(n,f,@fresp,w,'ftype')

 

Description

firpm designs a linear-phase FIR filter using the Parks-McClellan algorithm [1]. The Parks-McClellan algorithm uses the Remez exchange algorithm and Chebyshev approximation theory to design filters with an optimal fit between the desired and actual frequency responses. The filters are optimal in the sense that the maximum error between the desired frequency response and the actual frequency response is minimized. Filters designed this way exhibit an equiripple behavior. in their frequency responses and are sometimes called equiripple filters. firpm exhibits discontinuities at the head and tail of its impulse response due to this equiripple nature.

译文:

firpm 设 计了一个线性相位FIR滤波器,运用了Parks- McClellan算法[1]。该Parks- McClellan 算法使用雷米兹Remez交换算法和切比雪夫逼近理论,设计出了实际与所需的频率响应的最佳组合的滤波器。该滤波器在需要的频率响应和实际频率响应的最大 误差最小的意义上是最优的。滤波器这样设计的展示在他们的频率响应等波纹行为,有时也称为等波纹滤波器。 firpm  脉冲响应的头和尾 是不连续的,这是由于等波纹得性质。

Algorithm

firpm is a MEX-file version of the original Fortran code from [1], altered to design arbitrarily long filters with arbitrarily many linear bands.

firpm designs type I, II, III, and IV linear-phase filters. Type I and type II are the defaults for n even and n odd, respectively, while type III (n even) and type IV (n odd) are obtained with the 'hilbert' and 'differentiator' flags. The different types of filters have different symmetries and certain constraints on their frequency responses (see [5] for more details).


firpm  是MEX-file 文件版本, 原始Fortran代码形式,来设计具有任意线性多带的任意长度的滤波器[1]。

firpm  设计I型,Ⅱ,Ⅲ,Ⅳ的线性相位滤波器。 I型和II型,默认n为偶数和n为奇数,而III型(n为偶数)和IV型(n为奇数)是由'希尔伯特'和'差分器' 标志位产生的。不同类型的滤波器有不同的对称性,其频率响应也有一定的限制(详情请参阅[5])。

 

Examples

Graph the desired and actual frequency responses of a 17th-order Parks-McClellan bandpass filter:

f = [0 0.3 0.4 0.6 0.7 1]; a = [0 0 1 1 0 0];  b = firpm(17,f,a);  [h,w] = freqz(b,1,512);  plot(f,a,w/pi,abs(h))  legend('Ideal','firpm Design')  

 

----------------------------------------------------------------------------------------------

2. firls
    Least square linear-phase FIR filter design


Syntax

b = firls(n,f,a)
b = firls(n,f,a,w)
b = firls(n,f,a,'ftype')
b = firls(n,f,a,w,'ftype')


Description

firls designs a linear-phase FIR filter that minimizes the weighted, integrated squared error between an ideal piecewise linear function and the magnitude response of the filter over a set of desired frequency bands.


firls 设计了一个线性相位FIR滤波器,最大限度地减少了所需的频率波段的权重,综合了理想分段线性函数和滤波器的幅频响应的误差平方。

Algorithm

Reference [1] describes the theoretical approach behind firls. The function solves a system of linear equations involving an inner product matrix of size roughly n/2 using the MATLAB \ operator.

This function designs type I, II, III, and IV linear-phase filters. Type I and II are the defaults for n even and odd respectively, while the 'hilbert' and 'differentiator' flags produce type III (n even) and IV (n odd) filters. The various filter types have different symmetries and constraints on their frequency responses (see [2] for details).

 


参考文献[1]描述了firls 实现理论方法。该功函数解决了线性方程组,涉及内积大小大约n / 2个矩阵,利用MATLAB操作符。

这种函数设计I型,Ⅱ,Ⅲ,Ⅳ的线性相位滤波器。 I型和II是默认n为偶数和奇数,而'希尔伯特'和'差分器'标志产生III型(n为偶数)和
IV(n为奇数)滤波器。  各种滤波器类型有不同的对称性对它们的频率响应和限制(详见[2])。

Examples

Example 1
 

Design a 24th-order anti-symmetric filter with piecewise linear passbands and plot the desired and actual frequency response:

F = [0 0.3  0.4 0.6  0.7 0.9];   A = [0  1   0  0  0.5 0.5];  b = firls(24,F,A,'hilbert');  for i=1:2:6,      plot([F(i) F(i+1)],[A(i) A(i+1)],'--'), hold on  end  [H,f] = freqz(b,1,512,2);  plot(f,abs(H)), grid on, hold off  legend('Ideal','firls Design')

------------------------------------------------------------------------------------------------

3. fircls
    Constrained least square, FIR multiband filter design


Syntax

b = fircls(n,f,amp,up,lo)
fircls(n,f,amp,up,lo,'design_flag')


Description

b = fircls(n,f,amp,up,lo) generates a length n+1 linear phase FIR filter b. The frequency-magnitude characteristics of this filter match those given by vectors f and amp:


 

f is a vector of transition frequencies in the range from 0 to 1, where 1 corresponds to the Nyquist frequency. The first point of f must be 0 and the last point 1. The frequency points must be in increasing order.


 

amp is a vector describing the piecewise constant desired amplitude of the frequency response. The length of amp is equal to the number of bands in the response and should be equal to length(f)-1.


 

up and lo are vectors with the same length as amp. They define the upper and lower bounds for the frequency response in each band.


 

fircls always uses an even filter order for configurations with a passband at the Nyquist frequency (that is, highpass and bandstop filters). This is because for odd orders, the frequency response at the Nyquist frequency is necessarily 0. If you specify an odd-valued n, fircls increments it by 1.

fircls(n,f,amp,up,lo,'design_flag') enables you to monitor the filter design, where 'design_flag' can be


 

'trace', for a textual display of the design error at each iteration step.


 

'plots', for a collection of plots showing the filter's full-band magnitude response and a zoomed view of the magnitude response in each sub-band. All plots are updated at each iteration step. The O's on the plot are the estimated extremals of the new iteration and the X's are the estimated extremals of the previous iteration, where the extremals are the peaks (maximum and minimum) of the filter ripples. Only ripples that have a corresponding O and X are made equal.


 

'both', for both the textual display and plots.


-------------------------------------------------------------------------------------------

4. cfirpm
    Complex and nonlinear-phase equiripple FIR filter design


Syntax

b = cfirpm(n,f,@fresp)
b = cfirpm(n,f,@fresp,w)
b = cfirpm(n,f,a,w)
b = cfirpm(...,'sym')
b = cfirpm(...,'skip_stage2')
b = cfirpm(..., 'debug')
b = cfirpm(...,{lgrid})
[b,delta] = cfirpm(...)
[b,delta,opt] = cfirpm(...)


Description

cfirpm allows arbitrary frequency-domain constraints to be specified for the design of a possibly complex FIR filter. The Chebyshev (or minimax) filter error is optimized, producing equiripple FIR filter designs.


Algorithm

An extended version of the Remez exchange method is implemented for the complex case. This exchange method obtains the optimal filter when the equiripple nature of the filter is restricted to have n+2 extremals. When it does not converge, the algorithm switches to an ascent-descent algorithm that takes over to finish the convergence to the optimal solution. See the references for further details.

 

Examples

Example 1

Design a 31-tap, linear-phase, lowpass filter:

b = cfirpm(30,[-1 -0.5 -0.4 0.7 0.8 1],@lowpass);  fvtool(b,1)  

Click the Magnitude and Phase Response button.

 


Example 2

Design a nonlinear-phase allpass FIR filter:

n = 22;                    % Filter order  f = [-1 1];                % Frequency band edges  w = [1 1];                 % Weights for optimization  gf = linspace(-1,1,256);    % Grid of frequency points   d = exp(-1i*pi*gf*n/2 + 1i*pi*pi*sign(gf).*gf.*gf*(4/pi));                  % Desired frequency response  

Vector d now contains the complex frequency response that we desire for the FIR filter computed by cfirpm.

Now compute the FIR filter that best approximates this response:

b = cfirpm(n,f,'allpass',w,'real');  % Approximation  freqz(b,1,256,'whole');  subplot(2,1,1); hold on              % Overlay response  plot(pi*(gf+1),20*log10(abs(fftshift(d))),'r--')  subplot(2,1,2); hold on  plot(pi*(gf+1),unwrap(angle(fftshift(d)))*180/pi,'r--')  legend('Approximation','Desired')  

 


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 6

    粉丝
  • 0

    好友
  • 15

    获赞
  • 6

    评论
  • 105786

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-25 17:37 , Processed in 0.014619 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部