• 《DSP using MATLAB》Problem 8.37


    代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 8.37 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    % Digital Filter Specifications:   Chebyshev-2 bandpass
    ws = [0.30*pi 0.60*pi];             % digital stopband freq in rad
    wp = [0.40*pi 0.50*pi];             % digital passband freq in rad
    Rp = 0.50;                          % passband ripple in dB
    As = 50;                            % stopband attenuation in dB
    
    Ripple = 10 ^ (-Rp/20)           % passband ripple in absolute
    Attn = 10 ^ (-As/20)             % stopband attenuation in absolute
    
    % Calculation of Chebyshev-2 filter parameters:
    [N, wn] = cheb2ord(wp/pi, ws/pi, Rp, As);
    
    fprintf('
      ********* Chebyshev-2 Digital Bandpass Filter Order is = %3.0f 
    ', 2*N)
    
    % Digital Chebyshev-2 Bandpass Filter Design:
    [bbp, abp] = cheby2(N, As, wn);
    
    [C, B, A] = dir2cas(bbp, abp)
    
    % Calculation of Frequency Response:
    %[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
    [dbbp, magbp, phabp, grdbp, wwbp] = freqz_m(bbp, abp);
    
    % ---------------------------------------------------------------
    %    find Actual Passband Ripple and Min Stopband attenuation
    % ---------------------------------------------------------------
    delta_w = 2*pi/1000;
    Rp_bp = -(min(dbbp(ceil(wp(1)/delta_w+1):1:ceil(wp(2)/delta_w+1))));      % Actual Passband Ripple
    
    fprintf('
    Actual Passband Ripple is %.4f dB.
    ', Rp_bp);
    
    As_bp = -round(max(dbbp(1:1:ceil(ws(1)/delta_w)+1)));                    % Min Stopband attenuation
    fprintf('
    Min Stopband attenuation is %.4f dB.
    
    ', As_bp);
    
    
    %% -----------------------------------------------------------------
    %%                             Plot
    %% -----------------------------------------------------------------  
    
    figure('NumberTitle', 'off', 'Name', 'Problem 8.37 Chebyshev-2 bp by cheby2 function')
    set(gcf,'Color','white'); 
    M = 1;                          % Omega max
    
    subplot(2,2,1); plot(wwbp/pi, magbp); axis([0, M, 0, 1.2]); grid on;
    xlabel('Digital frequency in pi units'); ylabel('|H|'); title('Magnitude Response');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.9441, 1]);
    
    subplot(2,2,2); plot(wwbp/pi, dbbp); axis([0, M, -100, 2]); grid on;
    xlabel('Digital frequency in pi units'); ylabel('Decibels'); title('Magnitude in dB');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-80, -50, -1, 0]);
    set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '50';'1 ';' 0']);
    
    
    subplot(2,2,3); plot(wwbp/pi, phabp/pi); axis([0, M, -1.1, 1.1]); grid on;
    xlabel('Digital frequency in pi nuits'); ylabel('radians in pi units'); title('Phase Response');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
    
    subplot(2,2,4); plot(wwbp/pi, grdbp); axis([0, M, 0, 40]); grid on;
    xlabel('Digital frequency in pi units'); ylabel('Samples'); title('Group Delay');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0:10:40]);
    

      运行结果:

            通带、阻带绝对指标

            用cheby2函数(MATLAB自带),设计数字低通原型滤波器,阶数为5,系统函数串联形式的系数为

            Chebyshev-2型数字低通,幅度谱、相位谱和群延迟响应

  • 相关阅读:
    jsp session练习简单的登录
    JSP练习:编写登录程序,错误时跳转
    1.JSON抓取文件解析文件
    java ee 在数据库中执行增删改查
    java ee cookie方法键值对输出
    java ee cookie方法包括在cookie输出的中文转换
    java编写在数据库中按条件查询数据
    java 在数据库中添加新信息
    java ee 输出三角形
    java ee 五的阶乘
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/11728602.html
Copyright © 2020-2023  润新知