zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》示例Example 8.11

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Exameple 8.11 
    
    ');
    
    time_stamp = datestr(now, 31);
    [wkd1, wkd2] = weekday(today, 'long');
    fprintf('      Now is %20s, and it is %9s  
    
    ', time_stamp, wkd2);
    %% ------------------------------------------------------------------------
    
    % Digital Filter Specifications:
    wp = 0.2*pi;                 % digital passband freq in Hz
    ws = 0.3*pi;                 % digital stopband freq in Hz
    Rp = 1;                      % passband ripple in dB
    As = 15;                     % stopband attenuation in dB
    
    % Analog prototype specifications: Inverse Mapping for frequencies
    T = 1;                       % set T = 1
    OmegaP = wp/T;               % prototype passband freq
    OmegaS = ws/T;               % prototype stopband freq
    
    % Analog Butterworth Prototype Filter Calculation:
    [cs, ds] = afd_butt(OmegaP, OmegaS, Rp, As);
    
    % Impulse Invariance Transformation:
    [b, a] = imp_invr(cs, ds, T); [C, B, A] = dir2par(b, a)
    
    % Calculation of Frequency Response:
    [db, mag, pha, grd, ww] = freqz_m(b, a);
    
    
    %% -----------------------------------------------------------------
    %%                             Plot
    %% -----------------------------------------------------------------  
    
    figure('NumberTitle', 'off', 'Name', 'Exameple 8.11')
    set(gcf,'Color','white'); 
    M = 1;                          % Omega max
    
    subplot(2,2,1); plot(ww/pi, mag); 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.2, 0.3, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.1778, 0.8913, 1]);
    
    subplot(2,2,2); plot(ww/pi, pha/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.2, 0.3, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]);
    
    subplot(2,2,3); plot(ww/pi, db); axis([0, M, -30, 10]); grid on;
    xlabel('frequency in pi units'); ylabel('Decibels'); title('Magnitude in dB ');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [-30, -15, -1, 0]);
    
    
    subplot(2,2,4); plot(ww/pi, grd); axis([0, M, 0, 10]); grid on;
    xlabel('frequency in pi units'); ylabel('Samples'); title('Group Delay');
    set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, M]);
    set(gca, 'YTickMode', 'manual', 'YTick', [0:2:10]);
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    分享:两个栈实现一个队列的功能
    分享:要关注技术,但也要关注所做的事情
    linux网络编程中阻塞和非阻塞socket的区别
    分享:C++参数传递方式
    linux非阻塞socket教程
    有用和有趣的产品秤砣
    查找 grep r TFramedTransport *
    分享:SecureCRT使用VIM语法高亮
    linux 非阻塞 socket Google 搜索
    linux c语言 select函数用法 ITeye技术网站
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6702994.html
Copyright © 2011-2022 走看看