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

    第3小题:

    代码:

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.31 
    
    ');
    
    banner();
    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % -------------------------------------------------------------
    %   x3(n) --- N-point circular convolution of x1(n) an x2(n)  
    %   x4(n) ---          Linear convolution     
    %   e(n)  ---       error sequence                            
    % -------------------------------------------------------------
    
    N = 15;
    n1 = [0:9];
    x1 = 0.8.^n1;
    N1 = length(x1);
    
    n2 = [0:9];
    x2 = (-0.8).^n2;
    N2 = length(x2);
    
    
    % --------------------------------------------
    %        1st way ---- time domain
    % --------------------------------------------
    y1 = circonvt(x1, x2, N)
    ny1 = [0:N-1];
    
    
    % --------------------------------------------
    %   2nd way ----  DFT method
    % --------------------------------------------
    
    y2 = circonvf(x1, x2, N);
    ny2 = [0:N-1];
    
    
    % --------------------------------------------
    %   3rd way --- circulant matrix
    % --------------------------------------------
    
    y3 = circonvt_v3(x1, x2, N);
    ny3 = [0:N-1];
    
    % ---------------------------------------
    %     Linear convolution
    % ---------------------------------------
    
    [y4, ny4] = conv_m(x1, n1, x2, n2);
    
    e1 = y1 - y4(1:N);
    
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.31.3 x1(n) and x2(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n1, x1); 
    xlabel('n'); ylabel('x1(n)');
    title('x1(n)=0.8^n  N=10');  grid on;
    subplot(2,1,2); stem(n2, x2);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('n'); ylabel('x2(n)');
    title('x2(n)=(-0.8)^n  N=10');  grid on;
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.31.3 Cir-Conv and Linear-Conv')
    set(gcf,'Color','white'); 
    subplot(2,2,1); stem(ny1, y1); 
    xlabel('n'); ylabel('y1(n)');
    title('Cir-Conv (Time domain), y1(n)');  grid on;
    subplot(2,2,2); stem(ny2, y2);  
    %axis([0, N, 0, 1]);
    xlabel('n'); ylabel('y2(n)');
    title('Cir-Conv (DFT method), y2(n)');  grid on;
    subplot(2,2,3); stem(ny3, y3);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('n'); ylabel('y3(n)');
    title('Cir-Conv (circulant matrix), y3(n)');  grid on;
    subplot(2,2,4); stem(ny4, y4);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('n'); ylabel('y4(n)');
    title('Linear-Conv, y4(n)');  grid on;
    

      运行结果:

            这两个序列的圆周卷积结果(3种方法)、线性卷积结果

            其它小题的图这里不放了,大致步骤见文中程序。

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    2016阿里巴巴73款开源产品全向图
    在微软5年,我学到的几个小技能
    2016 年 Java 工具和技术的调查:IDEA 已超过
    PHP学习总结(9)——PHP入门篇之WAMPServer服务控制面板介绍
    Template Pattern & Strategy Pattern
    天之道,损有余而补不足。人之道,则不然,损不足以奉有余。孰能有余以奉天下?唯有道者
    [林锐13]面向对象程序设计方法概述
    [林锐8.4]函数指针
    ZT c++ 中的重载全局new,delete
    ZT 自定义operator new与operator delete的使用(1)
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/9474655.html
Copyright © 2011-2022 走看看