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

            昨晚手机在看X信的时候突然黑屏,开机重启都没反应,今天维修师傅说使用时间太长了,还是买个新的吧,心疼银子啊!

            这里只放前两个小题的图。

            代码:

            1、

    %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.28 
    
    ');
    
    banner();
    %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % -------------------------------------------------------------------
    %       Computer N-point Circular Convolution                      
    % -------------------------------------------------------------------
    n1 = [0:5];
    x1 = sin(pi*n1/3);
    N1 = length(x1);
    
    n2 = [0:7];
    x2 = cos(pi*n2/4);
    N2 = length(x2);
    
    
    % --------------------------------------------
    %        1st way TIME domain
    % --------------------------------------------
    N = 10;
    n = [0:N-1];
    
    y1 = circonvt(x1, x2, N);
    
    
    % --------------------------------------------
    %   2nd way ----  circular conv(FREQ domain)
    % --------------------------------------------
    y2 = circonvf(x1, x2, N);
    
    
    % --------------------------------------------
    %   3rd way --- Cir Conv (Circulant Matrix)
    % --------------------------------------------
    y3 = circonvt_v3(x1, x2, N);
    
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.28.1 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=6');  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.28.1 Cir-Conv, N=10')
    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([-N/2, N/2, -0.5, 50.5]);
    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;
    

      运行结果:

            计算圆周卷积的两序列

            三种方法计算圆周卷积

            2、

            代码:

    %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.28 
    
    ');
    
    banner();
    %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % -------------------------------------------------------------------
    %       Computer N-point Circular Convolution                      
    % -------------------------------------------------------------------
    N = 32;
    n1 = [0:N-1];
    x1 = cos(2*pi*n1/N);
    N1 = length(x1);
    
    n2 = [0:N-1];
    x2 = sin(2*pi*n2/N);
    N2 = length(x2);
    
    
    % --------------------------------------------
    %        1st way TIME domain
    % --------------------------------------------
    %N = 10;
    n = [0:N-1];
    
    y1 = circonvt(x1, x2, N);
    
    
    % --------------------------------------------
    %   2nd way ----  circular conv(FREQ domain)
    % --------------------------------------------
    y2 = circonvf(x1, x2, N);
    
    
    % --------------------------------------------
    %   3rd way --- Cir Conv (Circulant Matrix)
    % --------------------------------------------
    y3 = circonvt_v3(x1, x2, N);
    
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.28.2 x1(n) and x2(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n1, x1); 
    xlabel('n'); ylabel('x1(n)');
    title('x1(n)=cos(2*pi*n1/N), N=32');  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)=sin(2*pi*n2/N), N=32');  grid on;
    
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.28.2 Cir-Conv, N=32')
    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([-N/2, N/2, -0.5, 50.5]);
    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;
    

      运行结果:

            代码结构都一样

     

            圆周卷积结果

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    springcloud组件梳理之hystrix
    springcloud组件梳理之Feign
    React Native startReactApplication 方法简析
    FREE OFFER
    修改docker默认目录
    使用云效进行自动化构建和部署
    Git同时推送到多个远端仓库【转】
    OneNote出现we're sorry. OneNote is cleanning up from the last time it was open.
    【数学基础】数据科学的概率基础
    【摄影后期基础教程】Lightroom_秋凉视频教程
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/9465221.html
Copyright © 2011-2022 走看看