• 《DSP using MATLAB》Problem 2.15


    代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 2.15 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    
    nx1 = [-3:3]; x1 = [2, -4, 5, 3, -1, -2, 6]; 
    nh1 = [-1:3]; h1 = [1, -1, 1, -1, 1];
    
    nx2 = [-2:2]; x2 = [1, 1, 0, 1, 1];
    nh2 = [-3:0]; h2 = [1, -2, -3, 4];
    
    nx3 = [-2:6]; x3 = (0.25 .^ (-nx3)) .* (stepseq(-1, -2, 6) - stepseq(4, -2, 6));
    nh3 = [-2:6]; h3 = stepseq(0, -2, 6) - stepseq(5, -2, 6);
    
    nx4 = [-3:7]; x4 = (nx4/4) .* (stepseq(0, -3, 7) - stepseq(6, -3, 7)) ;
    nh4 = [-3:7]; h4 = 2 * (stepseq(-2, -3, 7) - stepseq(3, -3, 7));
    
    
    [y1, ny1] = conv_m(x1, nx1, h1, nh1);
    [y2, ny2] = conv_m(x2, nx2, h2, nh2);
    [y3, ny3] = conv_m(x3, nx3, h3, nh3);
    [y4, ny4] = conv_m(x4, nx4, h4, nh4);
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.15')
    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;
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.15')
    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;
    
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.15')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(3,1,1); stem(nx3, x3); title('x3 sequence');
    xlabel('n'); ylabel('x3(n)') ;
    grid on
    subplot(3,1,2); stem(nh3, h3); title('h3 sequence');
    xlabel('n'); ylabel('h3(n)');
    grid on;
    subplot(3,1,3); stem(ny3, y3); title('y3=x3*h3 sequence');
    xlabel('n'); ylabel('y3(n)');
    grid on;
    
    figure('NumberTitle', 'off', 'Name', 'Problem 2.15')
    set(gcf,'Color',[1,1,1])                  % 改变坐标外围背景颜色
    
    subplot(3,1,1); stem(nx4, x4); title('x4 sequence');
    xlabel('n'); ylabel('x4(n)') ;
    grid on
    subplot(3,1,2); stem(nh4, h4); title('h4 sequence');
    xlabel('n'); ylabel('h4(n)');
    grid on;
    subplot(3,1,3); stem(ny4, y4); title('y4=x4*h4 sequence');
    xlabel('n'); ylabel('y4(n)');
    grid on;
    

      运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    tomcat禁止查看文件目录
    jsp中的时间操作
    用 iframe 解决下拉框与层之冲突
    不要把灯泡放进口中
    一个高效简洁的Struts分页方法
    非常Cool的 网页特效(背景藏,alert样式)
    让table中的英文和数字换行
    隐藏多行文本框的滚动条
    tomcat默认首页设置
    如何利用回车来进行焦点转移呢
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8007391.html
Copyright © 2020-2023  润新知