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

         先由脉冲响应序列h(n)得到差分方程系数,过程如下:

    代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.16 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    
    %% ------------------------------------------------------
    %%              sequence of 51 samples
    %% ------------------------------------------------------
    nx1 = [-1:49]; x1 = (0.8 .^ nx1) .* stepseq(0, -1, 49);  
    nh1 = [-1:49]; h1 = ( (-0.9).^nh1 ) .* stepseq(0, -1, 49);
    
    [y1, ny1] = conv_m(x1, nx1, h1, nh1);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.16')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(3,1,1); stem(nx1, x1); title('x1 sequence');
    xlabel('n'); ylabel('x(n)') ;
    grid on
    subplot(3,1,2); stem(nh1, h1); title('h1 sequence');
    xlabel('n'); ylabel('h1(n)');
    grid on;
    subplot(3,1,3); stem(ny1, y1); title('y1=x1*h1 sequence');
    xlabel('n'); ylabel('y1(n)');
    grid on;
    
    
    %% -----------------------------------------------------
    %%         Trancate to 26 samples
    %% -----------------------------------------------------
    nx2 = [-1:24]; x2 = (0.8 .^ nx2) .* stepseq(0, -1, 24);  
    nh2 = [-1:24]; h2 = ( (-0.9).^nh2 ) .* stepseq(0, -1, 24);
    
    [y2, ny2] = conv_m(x2, nx2, h2, nh2);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.16')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(3,1,1); stem(nx2, x2); title('x2 sequence');
    xlabel('n'); ylabel('x2(n)') ;
    grid on
    subplot(3,1,2); stem(nh2, h2); title('h2 sequence');
    xlabel('n'); ylabel('h2(n)');
    grid on;
    subplot(3,1,3); stem(ny2, y2); title('y2=x2*h2 sequence');
    xlabel('n'); ylabel('y2(n)');
    grid on;
    
    
    %% ----------------------------------------------------------
    %%            filter function
    %% ----------------------------------------------------------
    b = [1]; a = [1, 0.9];
    
    y3 = filter(b, a, x1);
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.16')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    %subplot(3,1,3); 
    stem(nx1, y3); title('y3 sequence');
    xlabel('n'); ylabel('y3(n)');
    grid on;
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    记住我
    国米夺冠
    小谈“汉字转换成拼音(不带声调)”
    NLP资源共享盛宴
    文本分类资源和程序开源共享
    菜鸟进阶:C++实现Chisquare 特征词选择算法
    欢迎大家试用信息领域学科知识服务平台
    欢迎大家加入NLP,WEBIR,DATA Ming 的技术QQ群
    求两点之间所有路径的算法
    step by step 文本分类(一)
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8007428.html
Copyright © 2011-2022 走看看