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

    代码:

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.7 
    
    ');
    
    banner();
    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % --------------------------------------------------
    %        1  x(n) = [ 2,4,6,1,3,5 ]    N--period
    %                    |
    % --------------------------------------------------
    x = [2, 4, 6, 1, 3, 5]; N = 6; n = [0 : N-1];              % periodic sequence with period N
    y = x( mod(-n, N)+1 );                                     % circular fold
    
    figure('NumberTitle', 'off', 'Name', 'P5.7 x(n) and x(-n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(n, x);
    xlabel('n'); ylabel('x(n)');
    title('$	ilde x(n) sequence, period N=6$', 'interpreter', 'latex', 'fontsize', 14);  grid on;
    subplot(2,1,2); stem(n, y);
    xlabel('n'); ylabel('y(n)');
    title('x(-n) sequence');  grid on;
    
    
    %% ------------------------------------------------------------------
    %%                 DFS(k) of xn sequence, k=[0:N-1], N=6
    %% ------------------------------------------------------------------
    k1 = [0 : length(x)-1];
    %k2 = [-N : N-1];
    %k3 = [-N/2 : N/2];
    Xk_1 = dfs(x, N);                                         % DFS
    magXk = abs( [ Xk_1 ] );          % DFS magnitude
    angXk = angle( [Xk_1] )/pi;       % DFS angle
    
    figure('NumberTitle', 'off', 'Name', 'P5.7 DFS(k) of x(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(k1, magXk); %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('magnitude(k)');
    title('DFS magnitude of x(n), N=6');  grid on;
    subplot(2,1,2); stem(k1, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('angle(k)');
    title('DFS angle of x(n), N=6');  grid on;
    
    
    %% ------------------------------------------------------------------
    %%                 DFS(k) of yn sequence, k=[0:N-1], N=6
    %% ------------------------------------------------------------------
    k1 = [0 : length(y)-1];
    %k2 = [-N : N-1];
    %k3 = [-N/2 : N/2];
    Yk_1 = dfs(y, N);                 % DFS
    magYk = abs( [ Yk_1 ] );          % DFS magnitude
    angYk = angle( [Yk_1] )/pi;       % DFS angle
    
    figure('NumberTitle', 'off', 'Name', 'P5.7 DFS(k) of y(n)')
    set(gcf,'Color','white'); 
    subplot(2,1,1); stem(k1, magYk); %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('magnitude(k)');
    title('DFS magnitude of y(n), N=6');  grid on;
    subplot(2,1,2); stem(k1, angYk); %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('angle(k)');
    title('DFS angle of y(n), N=6');  grid on;
    

      运行结果:

            周期序列及其圆周折叠序列:

              原始序列的DFS系数

            圆周折叠序列的DFS系数

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    李开复给中国学生的第一封信
    vc++学习篇(三)——预处理命令之条件编译(#ifdef,#else,#endif,#if等)
    高级程序员考试时间安排和参考书推荐
    vc++学习篇(四)—— 指针
    程序员应具备的素质
    Word 2003 长篇文档排版技巧(二)
    Google 技巧集锦
    给中国学生的第二封信
    修复mysql表
    社保相关
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/9314201.html
Copyright © 2011-2022 走看看