zoukankan      html  css  js  c++  java
  • 《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、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    [转]DllMain中不当操作导致死锁问题的分析——DllMain中要谨慎写代码(完结篇)
    【机器学习】深入理解人工神经网络结构
    【机器学习】初识人工神经网络
    【机器学习】通过正则化解决过拟合问题
    【机器学习】逻辑回归
    【机器学习】用Octave实现一元线性回归的梯度下降算法
    【机器学习】对梯度下降算法的进一步理解
    【机器学习】从分类问题区别机器学习类型 与 初步介绍无监督学习算法 PAC
    【机器学习】感知机学习算法(PLA)
    【机器学习】1 监督学习应用与梯度下降
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8550917.html
Copyright © 2011-2022 走看看