• 《DSP using MATLAB》Problem 4.15


    只会做前两个,

     

     代码:

    %% ----------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 4.15 
    
    ');
    
    banner();
    %% ----------------------------------------------------------------------------
    
    
    %% ----------------------------------------------------
    %%            1      h(n)=[5(0.25)^n]u(n)
    %%                   x(n)=(0.25^n)u(n)
    %% ----------------------------------------------------
    n = [0:9];
    
    h1 = 5 * (1/4) .^ n .* stepseq(0, 0, 9);
    x  = (1/4) .^ n;
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 h1(n) x(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n, h1); 
    xlabel('n'); ylabel('h(n)'); grid on;
    title('h(n)=[5(1/4)^n]u(n)');
    subplot(2,1,2); stem(n, x);
    xlabel('n'); ylabel('x'); grid on;
    title('x(n)=(1/4)^nu(n)');
    
    
    b1 = [5]; a1 = [1, -1/4];                  
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 H1(z) pole-zero')
    set(gcf,'Color','white'); 
    zplane(b1, a1);
    title('pole-zero plot'); grid on;
    
    y1 = filter(b1, a1, x);
    
    [y1_chk, ny1_chk] = conv_m(h1, n, x, n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 y1(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem([0:length(y1)-1], y1); 
    xlabel('n'); ylabel('h(n)'); grid on;
    title('y(n)=filter(b, a, x)');
    subplot(2,1,2); stem(ny1_chk, y1_chk);
    xlabel('n'); ylabel('y'); grid on;
    title('y(n)=h(n)*x(n)');
    
    
    %% ----------------------------------------------------
    %%            2      h(n)=[n(1/3)^n+(-1/4)^n]u(n)
    %%                   x(n)=(0.25^n)u(n)
    %% ----------------------------------------------------
    n = [0:9];
    
    h2 = (n .* (1/3) .^ n + (-1/4) .^ n ) .* stepseq(0, 0, 9);
    x  = (1/4) .^ n;
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 h2(n) x(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n, h2); 
    xlabel('n'); ylabel('h(n)'); grid on;
    title('h(n)=[n(1/3)^n]u(n) + (-1/4)^nu(n)');
    subplot(2,1,2); stem(n, x);
    xlabel('n'); ylabel('x'); grid on;
    title('x(n)=(1/4)^nu(n)');
    
    %b2 = [0, 12, 48, -1]; a2 = [144, -24, -23, 2, 1];                  
    b2 = [1, -1/3, 7/36]; a2 = [1, -5/12, -1/18, 1/36];
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 H2(z) pole-zero')
    set(gcf,'Color','white'); 
    zplane(b2, a2);
    title('pole-zero plot'); grid on;
    
    y2 = filter(b2, a2, x);
    
    [y2_chk, ny2_chk] = conv_m(h2, n, x, n);
    
    figure('NumberTitle', 'off', 'Name', 'Problem 4.15 y2(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem([0:length(y2)-1], y2); axis([0, 9, 0, 1]);
    xlabel('n'); ylabel('h(n)'); grid on;
    title('y(n)=filter(b, a, x)');
    subplot(2,1,2); stem(ny2_chk, y2_chk); axis([0, 9, 0, 1]);
    xlabel('n'); ylabel('y'); grid on;
    title('y(n)=h(n)*x(n)');
    

      运行结果:

     

     

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    实战:上亿数据如何秒查(转)
    jquery json 操作(转)
    企业模式之Unit Of Work模式
    判断一个网站用什么服务器
    js面向对象的封装方法,【案例】
    直线拟合算法
    互联网公司年终奖哪家强?都是土豪啊
    wifidog用php实现验证流程
    想学android进来看看吧~ ~
    Android自己定义视图(一):带下划线的TextView
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8550917.html
Copyright © 2020-2023  润新知