• 《DSP using MATLAB》示例Example 8.30


    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Exameple 8.30 
    
    ');
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Now is %20s, and it is %8s  
    
    ', time_stamp, wkd2);
    %% ------------------------------------------------------------------------
    
    % Digital Filter Specifications:   Chebyshev-2 bandpass
    ws = [0.4*pi 0.7*pi];            % digital stopband freq in rad
    wp = [0.25*pi 0.8*pi];           % digital passband freq in rad
    Rp = 1;                          % passband ripple in dB
    As = 40;                         % stopband attenuation in dB
    
    % Calculation of Chebyshev-2 filter parameters:
    [N, wn] = cheb2ord(wp/pi, ws/pi, Rp, As);
    
    fprintf('
      ********* Chebyshev-2 Filter Order is = %3.0f 
    ', N)
    
    % Digital Elliptic Bandpass Filter Design:
    [bhp, ahp] = cheby2(N, As, ws/pi, 'stop');
    
    [C, B, A] = dir2cas(bhp, ahp)
    
    % Calculation of Frequency Response:
    %[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
    [dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp);
    
    
    %% -----------------------------------------------------------------
    %%                             Plot
    %% -----------------------------------------------------------------  
    
    figure('NumberTitle', 'off', 'Name', 'Exameple 8.30')
    set(gcf,'Color','white'); 
    M = 1;                          % Omega max
    
    subplot(2,2,1); plot(wwhp/pi, maghp); axis([0, M, 0, 1.2]); grid on;
    xlabel(' frequency in pi units'); ylabel('|H|'); title('Magnitude Response');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.4, 0.7, 0.8, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]);
    
    subplot(2,2,2); plot(wwhp/pi, dbhp); axis([0, M, -50, 2]); grid on;
    xlabel(' frequency in pi units'); ylabel('Decibels'); title('Magnitude in dB');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.4, 0.7, 0.8, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-50, -40, -1, 0]);
    
    subplot(2,2,3); plot(wwhp/pi, phahp/pi); axis([0, M, -1.1, 1.1]); grid on;
    xlabel('frequency in pi nuits'); ylabel('radians in pi units'); title('Phase Response');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.4, 0.7, 0.8, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
    
    subplot(2,2,4); plot(wwhp/pi, grdhp); axis([0, M, 0, 15]); grid on;
    xlabel('frequency in pi units'); ylabel('Samples'); title('Group Delay');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.4, 0.7, 0.8, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0:5:15]);
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    初始mysql语句
    MySQL 数据库 的安装和基本管理
    POJ 3685
    总结-LCT
    $亲属关系$
    一:包装好和吹出去 二:三国心得
    创业心得
    阿里前CEO卫哲的万字长文:被马云骂醒,看透B2B 10大核心问题!
    英雄不问出处, 看看商界大佬年轻时受过的苦
    最应该富养的,不是孩子是妻子!
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6741727.html
Copyright © 2020-2023  润新知