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

            代码:

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.29 
    
    ');
    
    banner();
    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % --------------------------------------------------------
    %       x1(n) and x2(n) ----  N-point sequence
    %        y(n) = x1(n) Cir-Conv x2(n)                      
    % --------------------------------------------------------
    N = 8;
    n1 = [0:N-1];
    x1 = [9, 4, -1, 4, -4, -1, 8, 3];
    N1 = length(x1);
    
    n2 = [0:N-1];
    x2 = [-5, 6, 2, -7, -5, 2, 2, -2];
    N2 = length(x2);
    
    sum_x1 = sum( x1( min(n1)+1 : max(n1)+1 ) )
    sum_x2 = sum( x2( min(n2)+1 : max(n2)+1 ) )
    
    answer = sum_x1 * sum_x2
    
    % --------------------------------------------
    %        1st way TIME domain
    % --------------------------------------------
    %N = 10;
    n = [0:N-1];
    
    y1 = circonvt(x1, x2, N);
    sum_y1 = sum( y1( min(n)+1 : max(n)+1 ) )
    
    % --------------------------------------------
    %   2nd way ----  circular conv(FREQ domain)
    % --------------------------------------------
    y2 = circonvf(x1, x2, N);
    sum_y2 = sum( y2( min(n)+1 : max(n)+1 ) )
    
    % --------------------------------------------
    %   3rd way --- Cir Conv (Circulant Matrix)
    % --------------------------------------------
    y3 = circonvt_v3(x1, x2, N);
    sum_y3 = sum( y3( min(n)+1 : max(n)+1 ) )
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.29 x1(n) and x2(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n1, x1); 
    xlabel('n'); ylabel('x1(n)');
    title('x1(n)  N=8');  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)  N=8');  grid on;
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.29 Cir-Conv, N=8')
    set(gcf,'Color','white'); 
    subplot(3,1,1); stem(n, y1); 
    xlabel('n'); ylabel('y1(n)');
    title('Time Domain, y1(n)');  grid on;
    subplot(3,1,2); stem(n, y2);  
    %axis([0, N, 0, 1]);
    xlabel('n'); ylabel('y2(n)');
    title('FREQ domain, y2(n)');  grid on;
    subplot(3,1,3); stem(n, y3);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('n'); ylabel('y3(n)');
    title('Circulant Matrix, y3(n)');  grid on;
    

      运行结果:

            圆周卷积结果,3种计算方法。

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    C#使用Task创建任务
    Java编程思想学习(二)一切都是对象
    Java编程思想学习(一)对象导论中多态的理解
    【源码】sql__备份数据库1__bak数据库__存储过程
    【源码】自己写的Msg
    【情感】女人永远是期望男人主动的
    sql函数 手机品牌
    【源码】继承pagebase 权限判断
    【源码】Sql Server 2005 如何自动备份数据库
    sql 将smslog拆分3天3月内,3月外表
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/9472304.html
Copyright © 2011-2022 走看看