matlab中fir2,Frequency sampling-based FIR filter design

Design an FIR filter with the following frequency response:

A sinusoid between 0 and 0.18π rad/sample.

F1 = 0:0.01:0.18;

A1 = 0.5+sin(2*pi*7.5*F1)/4;

A piecewise linear section between 0.2π rad/sample and 0.78π rad/sample.

F2 = [0.2 0.38 0.4 0.55 0.562 0.585 0.6 0.78];

A2 = [0.5 2.3 1 1 -0.2 -0.2 1 1];

A quadratic section between 0.79π rad/sample and the Nyquist frequency.

F3 = 0.79:0.01:1;

A3 = 0.2+18*(1-F3).^2;

Design the filter using a Hamming window. Specify a filter order of 50.

N = 50;

FreqVect = [F1 F2 F3];

AmplVect = [A1 A2 A3];

ham = fir2(N,FreqVect,AmplVect);

Repeat the calculation using a Kaiser window that has a shape parameter of 3.

kai = fir2(N,FreqVect,AmplVect,kaiser(N+1,3));

Redesign the filter using the designfilt function. designfilt uses a rectangular window by default. Compute the zero-phase response of the filter over 1024 points.

d = designfilt('arbmagfir','FilterOrder',N, ...

'Frequencies',FreqVect,'Amplitudes',AmplVect);

[zd,wd] = zerophase(d,1024);

Display the zero-phase responses of the three filters. Overlay the ideal response.

zerophase(ham,1)

hold on

zerophase(kai,1)

plot(wd/pi,zd)

plot(FreqVect,AmplVect,'k:')

legend('Hamming','Kaiser','designfilt','ideal')

9b09794a0e3a04b4a1a8441afb4e6770.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值