• 《DSP using MATLAB》Problem 8.17


    代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 8.17 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    Wp = 0.5*pi; Ws = 0.8*pi; Rp = 0.25; As = 40;
    Fp = Wp/(2*pi);
    Fs = Ws/(2*pi);
    
    Ripple = 10 ^ (-Rp/20)
    Attn = 10 ^ (-As/20)
    
    % Analog filter design, DIRECT form:
    [b, a] = afd('cheby2', Fp, Fs, Rp, As);
    %[b, a] = afd_chb2(Wp, Ws, Rp, As);
    
    % Calculation of second-order sections:
    [C, B, A] = sdir2cas(b, a);
    
    % Calculation of Frequency Response:
    [db, mag, pha, ww] = freqs_m(b, a, 1*pi);
    
    % Calculation of Impulse Response:
    [ha, x, t] = impulse(b, a);
    
    
    %% -------------------------------------------------
    %%                    Plot
    %% -------------------------------------------------  
    
    figure('NumberTitle', 'off', 'Name', 'Problem 8.17 Lowpass Analog Chebyshev-2')
    set(gcf,'Color','white'); 
    M = 1.0;                          % Omega max
    
    subplot(2,2,1); plot(ww/pi, mag);  grid on; axis([-1, 1, 0, 1.2]);
    xlabel(' Analog frequency in pi*1k units'); ylabel('|H|'); title('Magnitude in Absolute');
    set(gca, 'XTickMode', 'manual', 'XTick', [-0.8, -0.5, 0, 0.5, 0.8]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.01, 0.97, 1]);
    
    subplot(2,2,2); plot(ww/pi, db);  grid on; %axis([0, M, -50, 10]);
    xlabel('Analog frequency in pi*1k units'); ylabel('Decibels'); title('Magnitude in dB ');
    set(gca, 'XTickMode', 'manual', 'XTick', [-0.8, -0.5, 0, 0.5, 0.8]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-70, -40, -1, 0]);
    set(gca,'YTickLabelMode','manual','YTickLabel',['70';'40';' 1';' 0']);
    
    subplot(2,2,3); plot(ww/pi, pha/pi);  grid on; axis([-1, 1, -1.2, 1.2]);
    xlabel('Analog frequency in pi*1k nuits'); ylabel('radians'); title('Phase Response');
    set(gca, 'XTickMode', 'manual', 'XTick', [-0.8, -0.5, 0, 0.5, 0.8]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
    
    
    subplot(2,2,4); plot(t, ha); grid on; %axis([0, 30, -0.05, 0.25]); 
    xlabel('time in seconds'); ylabel('ha(t)'); title('Impulse Response');
    

      运行结果:

           滤波器绝对指标

            模拟chebyshev-2型低通滤波器,串联形式系数

            幅度谱、相位谱和脉冲响应

            幅度谱进行放大

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    Ural 1099 Work Scheduling (一般图的最大匹配:带花树算法)
    HDU 4687 Boke and Tsukkomi (2013.8.20 多校9 1002)(暴力+带花树算法)
    2013 Multi-University Training Contest 9 小结(2013.8.20)
    TeX代码模板(持续更新中)
    POJ 3177 Redundant Paths
    POJ 1904 King's Quest
    hdu 4685 Prince and Princess (2013.8.15 多校8---1010)
    2-SAT模板(修改自LRJ的模板)
    HDU 3622 Bomb Game
    Ubuntu 压缩命令
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/11053955.html
Copyright © 2020-2023  润新知