• 《DSP using MATLAB》Problem 5.22


    代码:

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 5.22 
    
    ');
    
    banner();
    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    % -------------------------------------------------------------------
    %          512-point DFT of a real-valued sequence x(n)     
    %                                
    % -------------------------------------------------------------------
     k = [0:511];
    Xk_DFT = [zeros(1, 512)];
     
    Xk_DFT(0+1) = 20;    Xk_DFT(5+1) = 20+j*30;    Xk_DFT(32+1) = -10+j*15;   Xk_DFT(152+1) = 17+j*23;
    Xk_DFT(256+1) = 30;  Xk_DFT(360+1) = 17-j*23;  Xk_DFT(480+1) = -10-j*15;  Xk_DFT(507+1) = 20-j*30;
    
     N = length(Xk_DFT);
    
    
        magXk_DFT = abs( [ Xk_DFT ] );                                    % DFT magnitude
        angXk_DFT = angle( [Xk_DFT] )/pi;                                 % DFT angle
       realXk_DFT = real(Xk_DFT); 
       imagXk_DFT = imag(Xk_DFT);
    
    EXk = sum(abs(Xk_DFT).^2)/N
    
     x = real(idft(Xk_DFT, N));
     n = [0:N-1];
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.22 X(k), DFT of x(n)')
    set(gcf,'Color','white'); 
    subplot(2,2,1); stem(k, magXk_DFT); 
    xlabel('k'); ylabel('magnitude(k)');
    title('magnitude DFT of x(n), N=512');  grid on;
    subplot(2,2,3); stem(k, angXk_DFT);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('angle(k)');
    title('angle DFT of x(n), N=512');  grid on;
    subplot(2,2,2); stem(k, realXk_DFT); 
    xlabel('k'); ylabel('real (k)');
    title('real DFT of x(n), N=512');  grid on;
    subplot(2,2,4); stem(k, imagXk_DFT);  
    %axis([-N/2, N/2, -0.5, 50.5]);
    xlabel('k'); ylabel('imag (k)');
    title('imag DFT of x(n), N=512');  grid on;   
    
    
    figure('NumberTitle', 'off', 'Name', 'P5.22 x(n)')
    set(gcf,'Color','white'); 
    %subplot(3,1,1); 
    stem(n, x); 
    xlabel('n'); ylabel('x(n)');
    title('x(n), N=512');  grid on;
    

      运行结果:

           把alpha beta, k1、k2、k3求出来后,得知512点DFT有8个点不为零,如下图

            进行IDFT,得到时间域序列x(n)

            时间信号的能量

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    Qt——QLineEdit使用总结
    qt中的lineEdit文本输入框的输入类型限制(三种验证类)
    qt 创建线程
    linux 安装和卸载软件
    c 结构体中的变长数组
    Qt之QSS(QDarkStyleSheet)
    Qt之QSS(Q_PROPERTY-原始属性)
    Qt之QSS(Q_PROPERTY-自定义属性)
    Qt之QSS(白色靓丽)
    Qt之QSS(样式表语法)
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/9440211.html
Copyright © 2020-2023  润新知