• 《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、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    利用Oracle分析函数row_number和sys_connect_by_path实现多行数据合并为一行
    public string err属性
    table冻结表头和列[转]
    转:Js日期操作
    ASP.NET中JSON的序列化和反序列化
    javascript Date format(js日期格式化) [转]
    刚开通的博客
    调用图片
    散记兼容,需要整理
    ie6、div高度低于字体大小、则继承fontsize
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8016420.html
Copyright © 2020-2023  润新知