zoukankan      html  css  js  c++  java
  • DSP using MATLAB 示例 Example3.10

    用到的性质

    上代码:

    n = -5:10; x = rand(1,length(n)) + j * rand(1,length(n)); 
    k = -100:100; w = (pi/100)*k;                 % freqency between -pi and +pi  ,   [0,pi] axis divided into 101 points.
    X = x * (exp(-j*pi/100)) .^ (n'*k);           % DTFT of x
    
    % conjugation property
    y = conj(x);                                  % signal conjugation
    Y = y * (exp(-j*pi/100)) .^ (n'*k);           % DTFT of y 
    
    magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
    magY = abs(Y); angY = angle(Y); realY = real(Y); imagY = imag(Y);
    
    %verification
    Y_check = conj(fliplr(X));                    % conj(X(-w))    DTFT flip first, then conjugation
    error = max(abs(Y-Y_check));                  % Difference
    
    figure('NumberTitle', 'off', 'Name', 'x & y sequence')
    set(gcf,'Color','white'); 
    subplot(2,2,1); stem(n,real(x)); title('x sequence Real Part');         xlabel('n'); ylabel('Real x(n)'); grid on;
    subplot(2,2,2); stem(n,imag(x)); title('x sequence Imaginary Part');    xlabel('n'); ylabel('Imaginary x(n))'); grid on;
    subplot(2,2,3); stem(n,real(y)); title('y sequence Real Part');         xlabel('n'); ylabel('Real y(n)'); grid on;
    subplot(2,2,4); stem(n,imag(y)); title('y sequence Imaginary Part');    xlabel('n'); ylabel('Imaginary y(n))'); grid on;
    
    
    %% ----------------------------------------------------------------
    %%        START Graphical verification
    %% ----------------------------------------------------------------
    figure('NumberTitle', 'off', 'Name', 'X Y compare theirs Magnitude and Angle');
    set(gcf,'Color','white'); 
    subplot(2,2,1); plot(w/pi,magX); grid on; axis([-1,1,0,12]);
    xlabel('frequency in pi units'); ylabel('|X|'); title('Magnitude of X ');
    subplot(2,2,2); plot(w/pi,angX/pi); grid on; axis([-1,1,-1,1]);
    xlabel('frequency in pi units'); ylabel('Radians/pi'); title('Angle of X ');
    
    subplot(2,2,3); plot(w/pi,magY); grid on; axis([-1,1,0,12]);
    xlabel('frequency in pi units'); ylabel('|Y|'); title('Magnitude of Y ');
    subplot(2,2,4); plot(w/pi,angY/pi); grid on; axis([-1,1,-1,1]);
    xlabel('frequency in pi units'); ylabel('Radians/pi'); title('Angle of Y ');
    
    %% ----------------------------------------------------------------
    %%        END Graphical verification
    %% ----------------------------------------------------------------
    

     运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    重构drf后的环境变量配置
    分离的前后台交互
    虚拟环境的搭建
    Python
    Python
    Python
    Python操作MongoDb数据库
    Python操作SQLite/MySQL/LMDB
    数据库-如何创建SQL Server身份验证用户
    Python
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6068346.html
Copyright © 2011-2022 走看看