zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》Problem 2.19

    代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.19 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    b = [1, 2, 0, 1]; a = [1, -0.5, 0.25];
    n = [0:100];
    
    h1 = impz(b, a, n);
    
    x = impseq(0, 0, 100);
    
    h2 = filter(b, a, x);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.19 Impulse response')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(2,1,1); stem(n, h1); title('impz function');
    xlabel('n'); ylabel('h1(n)') ;
    grid on
    subplot(2,1,2); stem(n, h2); title('filter function');
    xlabel('n'); ylabel('h2(n)');
    grid on;
    
    %% ---------------------------------------------
    %%       stability
    %% ---------------------------------------------
    
    fprintf('
    1st impz  :  sum(abs(h)) = %f 
    ', sum(abs(h1)));
    fprintf('
    2nd filter:  sum(abs(h)) = %f 
    ', sum(abs(h2)));
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.19 Zero-Pole')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    pzmap(b, a);
    
    z = roots(a); magz = abs(z)
    
    
    
    %% --------------------------------------
    %%           another input
    %% --------------------------------------
    n2 = [0:200];
    x2 = (5 + 3*cos(0.2*pi*n2) + 4*sin(0.6*pi*n2)) .* stepseq(0, 0, 200);
    
    y2 = filter(b, a, x2);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.19 Another input')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(2,1,1); stem(n2, x2); title('input');
    xlabel('n2'); ylabel('x2(n)') ;
    grid on
    subplot(2,1,2); stem(n2, y2); title('Output');
    xlabel('n2'); ylabel('y2(n)');
    grid on;
    

      运行结果:

              上图是分别用impz和filter函数得到的脉冲响应序列。

              系统的脉冲响应序列是绝对可和的,另外系统的极点都位于单位圆内部(见下图),所以系统是稳定的。

              给系统一个新的输入,计算新的输出,如下图:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    ZOJ 2588 Burning Bridges
    POJ 1966 ZOJ 2182 Cable TV Network
    HDU 5348 MZL's endless loop
    HDU 5352 MZL's City
    Tarjan算法求解无向连通图的割点、割边、点双连通分量和边双连通分量的模板
    ZOJ 1119 SPF
    HDU 3452 Bonsai
    HDU 1520 Anniversary party
    POJ 2239 Selecting Courses
    POJ 1144 Network
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8016420.html
Copyright © 2011-2022 走看看