zoukankan      html  css  js  c++  java
  • FIR滤波器设计流程 加窗 MATLAB

     

    1.确定参数:

    Wp 通带截止频率

    Ws  阻带截止频率

    As  衰减dB

    Rp   纹波dB

    2.根据参数确定理想 频率响应 (M     (Wp + Ws )/2  )

    双边响应 wps_clip_image-217

    3.选窗

    过滤带宽

    阻带衰减

    4.得出最终响应

    时域相乘 频域卷积

    5.观察各项参数是否达标(采用归一化后的数据)

    衰减

    幅频特性

    相频

    群延时 ??

    ···

    Ps:观察频率响应的函数

    wps_clip_image-14168

    这里a = 1 因为FIR可由差分方程描述

    wps_clip_image-23954

    故分母为1

    代码:

    wp =0.2*pi;

    ws = 0.3*pi;

    tr_width = ws -wp;

    M = ceil(6.6*pi/tr_width)+1;

    n = [0:1:M-1];

    wc = ((ws + wp)/2) %ideal LPF cutoff frequency

    hd = ideal_lp(wc,M);

    w_ham = (hamming(M))';

    h = hd .* w_ham;

    [db,mag,pha,grd,w] = freqz_m(h,[1]);

    delta_w = 2*pi/1000;

    Rp = -(min(db(1:1:wp/delta_w+1)));

    As = -round(max(db(ws/delta_w+1:1:501)));

    %plot

    subplot(2,2,1);

    stem(n,hd);

    title('Ideal Impulse Response');

    axis([0 M-1 -0.1 0.3]);

    xlabel('n');

    ylabel('hd(n)');

    subplot(2,2,2);

    stem(n,w_ham);

    title(' Hamming Window');

    axis([0 M-1 0 1.1]);

    xlabel('n');

    ylabel('w(n)');

    subplot(2,2,3);

    stem(n,h);

    title('Actual Impluse Response');

    axis([0 M-1 -0.1 0.3]);

    xlabel('n');

    ylabel('h(n)');

    subplot(2,2,4);

    plot(w/pi,db);

    title('Magnitude Response in dB');grid

    axis([0 1 -100 10]);

    xlabel('frequency in pi units');

    ylabel('Decibels');

    wps_clip_image-890

    带通:

    wp1 =0.35*pi;

    ws1 = 0.2*pi;

    wp2 =0.65*pi;

    ws2 = 0.8*pi;

    tr_width = min((wp1 -ws1),(ws2 - wp2));

    M = ceil(11*pi/tr_width)+1;

    M

    n = [0:1:M-1];

    wc1 = ((ws1 + wp1)/2);

    wc2 = ((ws2 + wp2)/2);

    hd = ideal_lp(wc2,M)-ideal_lp(wc1,M);

    w_ham = (blackman(M))';

    h = hd .* w_ham;

    [db,mag,pha,grd,w] = freqz_m(h,[1]);

    delta_w = 2*pi/1000;

    Rp = -(min(db(wp1/delta_w+1:1:wp2/delta_w+1)));

    Rp

    As = -round(max(db(ws2/delta_w+1:1:501)));

    As

    %plot

    subplot(2,2,1);

    stem(n,hd);

    title('Ideal Impulse Response');

    axis([0 M-1 -0.5 0.5]);

    xlabel('n');

    ylabel('hd(n)');

    subplot(2,2,2);

    stem(n,w_ham);

    title(' blackman Window');

    axis([0 M-1 0 1.1]);

    xlabel('n');

    ylabel('w(n)');

    subplot(2,2,3);

    stem(n,h);

    title('Actual Impluse Response');

    axis([0 M-1 -0.5 0.5]);

    xlabel('n');

    ylabel('h(n)');

    subplot(2,2,4);

    plot(w/pi,db);

    title('Magnitude Response in dB');grid

    axis([0 1 -150 10]);

    xlabel('frequency in pi units');

    ylabel('Decibels');

    wps_clip_image-8587

    wps_clip_image-4446

  • 相关阅读:
    综合实例-文本框类部件
    输入掩码
    WebP,Jpeg,Png格式图片的编解码区别
    美团点评提前批面经
    Android中AIDL的使用详解,如何发起回调?
    JNI在Android中的实践NDK:Hello World
    Timer实现原理
    百度秋招凉经:客户端测开
    阿里秋招面经:Android客户端开发工程师
    Picasso和Glide区别
  • 原文地址:https://www.cnblogs.com/sleepy/p/2124269.html
Copyright © 2011-2022 走看看