zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》示例Example7.8

           窗函数的设计思想就是选择一个理想的频率选择滤波器(通常其脉冲响应函数是

    非因果、无限长的),然后截断(取窗)这个无限长脉冲响应,得到一个线性相位、因果的

    FIR滤波器。频率域示意图如下:

            我们的目的:对于给定的要求,选择滤波器长度M和窗函数ω(n),该窗函数要有最窄的主瓣宽度和最小的旁瓣衰减。

            前人为我们已经找好了许多窗函数,见下表:

    代码:

    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)))    % Actual Passband Ripple
    
    As = -round(max(db(ws/delta_w+1:1:501)))   % Min Stopband attenuation
    
    %Plot
    
    figure('NumberTitle', 'off', 'Name', 'Exameple 7.8')
    set(gcf,'Color','white'); 
    
    subplot(2,2,1); stem(n, hd); axis([0 M-1 -0.1 0.3]); grid on;
    xlabel('n'); ylabel('hd(n)'); title('Ideal Impulse Response');
    
    subplot(2,2,2); stem(n, w_ham); axis([0 M-1 0 1.1]); grid on;
    xlabel('n'); ylabel('w(n)'); title('Hamming Window');
    
    subplot(2,2,3); plot(n, h); axis([0 M-1 -0.1 0.3]); grid on;
    xlabel('n'); ylabel('h(n)'); title('Actual Impulse Response');
    
    subplot(2,2,4); plot(w/pi, db); axis([0 1 -100 10]); grid on;
    xlabel('frequency in pi units'); ylabel('Decibels'); title('Magnitude Response in dB');
    

      运行结果:

     

          我们注意到滤波器长度M=67,通带震荡0.0394dB,阻带衰减52dB。满足设计要求。

          代码中求Rp和As的方法强烈推荐,后文经常用到。

      

            

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    yii2 动态配置日志(log)
    Yii2 增删改查(CRUD)
    php curl数据传输神器
    Yii Cache 缓存的使用
    svn提交后 添加注释
    php file()函数
    maven + bat 实现快速编译打包模块代码
    获取SpringMVC所有的rest接口及其对应函数信息
    IntelliJ IDEA #region 代码折叠
    maven+Spring+SpringMVC+Hibernate快速搭建
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6622317.html
Copyright © 2011-2022 走看看