数字信号处理FIR 和 IIR 滤波器

目录

一、设计FIR滤波器

二、设计IIR滤波器

三、最终实验报告


一、设计FIR滤波器

Program your own function for digital low pass FIR filter design, using the windowing
method.

Experiment Content

. The process of Programming

Step1: Choose a pass band edge frequency in Hz for the filter in the middle of the transition width:

Step2:Calculate.and substitute this value into.

Step3: Choose a window that will satisfy the stop band attenuation. Calculate the number of terms N that will meet the transition width requirement. Choose an odd number so that the impulse response will be perfectly symmetrical.

Step4: Calculate the finite impulse response:.

Step5: Shift the impulse response values to ensure the causality.

function b=firwindow(f_pass,f_stop,fs,A_stop)
    fc=(f_pass+f_stop)/2;
    wc=2*pi*fc/fs;%设计的理想滤波器的截止频率
    %根据阻带衰减选择合适的窗函数
    if(A_stop<=21)   
            N=0.91*fs/(f_stop-f_pass)
            window=1
    elseif(A_stop<=44)
            N=3.32*fs/(f_stop-f_pass)
            window=2
    elseif (A_stop<=55)
            N=3.44*fs/(f_stop-f_pass)
            window=3
    else  (A_stop<=75)
            N=5.98*fs/(f_stop-f_pass) 
            window=4    
    end
    %窗函数点数N向上取整,且要求必须为奇数
    if(mod(ceil(N),2))
        N=ceil(N)
    else N=ceil(N)+1
    end
    n=-(N-1)/2:(N-1)/2;
    switch  window
        case 1
            window=ones(1,N);
        case 2
            window=0.5+0.5*cos(2*pi*n/(N-1));
        case 3
            window=0.54+0.46*cos(2*pi*n/(N-1));
        case 4
            window=0.42+0.5*cos(2*pi*n/(N-1))+0.08*cos(4*pi*n/(N-1));        
    end
    %与理想低通滤波器的时域表达式相乘,得到加窗后的低通滤波器
    b=window.*sin(wc*n)./(pi*n);
    %n=0处MATLAB计算有问题,需要手动调整,同时相当于向右调整为因果序列
    b=[b(1:(N-1)/2) wc/pi b((N+1)/2+1:N)];
end

二、设计IIR滤波器

Program your own function for first order Butterworth digital IIR filter design, using the
Bilinear Transformation with prewarping.

function [b, a] = iirbutter(fp1,fs)
wp1=2*pi*fp1/fs;
Wc=2*fs*tan(wp1/2);
a=[1,(Wc-2*fs)/(Wc+2*fs)];
b=[Wc/(Wc+2*fs) Wc/(Wc+2*fs)];
end

三、最终实验报告

实验分数应该会很不错,有兴趣的学弟可以学习一下 

 

 

 

 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

No_one-_-2022

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值