• 《DSP using MATLAB》 Problem 3.19


            先求模拟信号经过采样后,对应的数字角频率:

            明显看出,第3种采样出现假频了。DTFT是以2π为周期的,所以假频出现在10π-2kπ=0处。

            代码:

    %% ------------------------------------------------------------------------
    %%            Output Info about this m-file
    fprintf('
    ***********************************************************
    ');
    fprintf('        <DSP using MATLAB> Problem 3.19 
    
    ');
    
    banner();
    %% ------------------------------------------------------------------------
    
    
    %% -------------------------------------------------------------------
    %%                     xa(t)=sin(1000pit) 
    %% -------------------------------------------------------------------
    Ts = 0.0001;         % second unit
    n1 = [-100:100];
    
    x1 = sin(1000*pi*n1*Ts);
    
    figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.19 Ts = %.4f', Ts));
    set(gcf,'Color','white'); 
    %subplot(2,1,1);
    stem(n1, x1); 
    xlabel('n'); ylabel('x');  
    title(sprintf('x1(n) input sequence, Ts = %.4f', Ts)); grid on;
    
    M = 500;
    [X1, w] = dtft1(x1, n1, M);
    
    magX1  = abs(X1);  angX1  = angle(X1);  realX1  = real(X1);  imagX1  = imag(X1);
    
    %% --------------------------------------------------------------------
    %%              START X(w)'s  mag ang real imag
    %% --------------------------------------------------------------------
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X1');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi,magX1); grid on;  %axis([-1,1,0,1.05]); 
    title('Magnitude Response');
    xlabel('frequency in pi units'); ylabel('Magnitude  |H|'); 
    subplot(2,1,2); plot(w/pi, angX1/pi); grid on;  %axis([-1,1,-1.05,1.05]);
    title('Phase Response');
    xlabel('frequency in pi units'); ylabel('Radians/pi');
    
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X1');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi, realX1); grid on;
    title('Real Part');
    xlabel('frequency in pi units'); ylabel('Real');
    subplot(2,1,2); plot(w/pi, imagX1); grid on;
    title('Imaginary Part');
    xlabel('frequency in pi units'); ylabel('Imaginary');
    %% -------------------------------------------------------------------
    %%             END X's  mag ang real imag
    %% -------------------------------------------------------------------
    
    
    % ----------------------------------------------------------
    %                Ts=0.001s
    % ----------------------------------------------------------
    Ts = 0.001;         % second unit
    n2 = [-100:100];
    
    x2 = sin(1000*pi*n2*Ts);
    
    figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.19 Ts = %.4f', Ts));
    set(gcf,'Color','white'); 
    %subplot(2,1,1);
    stem(n2, x2); 
    xlabel('n'); ylabel('x');  
    title(sprintf('x2(n) input sequence, Ts = %.4f', Ts)); grid on;
    
    M = 500;
    [X2, w] = dtft1(x2, n2, M);
    
    magX2  = abs(X2);  angX2  = angle(X2);  realX2  = real(X2);  imagX2  = imag(X2);
    
    %% --------------------------------------------------------------------
    %%              START X(w)'s  mag ang real imag
    %% --------------------------------------------------------------------
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X2');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi,magX2); grid on;  %axis([-1,1,0,1.05]); 
    title('Magnitude Response');
    xlabel('frequency in pi units'); ylabel('Magnitude  |H|'); 
    subplot(2,1,2); plot(w/pi, angX2/pi); grid on;  %axis([-1,1,-1.05,1.05]);
    title('Phase Response');
    xlabel('frequency in pi units'); ylabel('Radians/pi');
    
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X2');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi, realX2); grid on;
    title('Real Part');
    xlabel('frequency in pi units'); ylabel('Real');
    subplot(2,1,2); plot(w/pi, imagX2); grid on;
    title('Imaginary Part');
    xlabel('frequency in pi units'); ylabel('Imaginary');
    %% -------------------------------------------------------------------
    %%             END X's  mag ang real imag
    %% -------------------------------------------------------------------
    
    
    
    % ----------------------------------------------------------
    %                Ts=0.01s
    % ----------------------------------------------------------
    Ts = 0.01;         % second unit
    n3 = [-100:100];
    
    x3 = sin(1000*pi*n3*Ts);
    
    figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.19 Ts = %.4f', Ts));
    set(gcf,'Color','white'); 
    %subplot(2,1,1);
    stem(n3, x3); 
    xlabel('n'); ylabel('x');  
    title(sprintf('x3(n) input sequence, Ts = %.4f', Ts)); grid on;
    
    M = 500;
    [X3, w] = dtft1(x3, n3, M);
    
    magX3  = abs(X3);  angX3  = angle(X3);  realX3  = real(X3);  imagX3  = imag(X3);
    
    %% --------------------------------------------------------------------
    %%              START X(w)'s  mag ang real imag
    %% --------------------------------------------------------------------
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X3');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi,magX3); grid on;  %axis([-1,1,0,1.05]); 
    title('Magnitude Response');
    xlabel('frequency in pi units'); ylabel('Magnitude  |H|'); 
    subplot(2,1,2); plot(w/pi, angX3/pi); grid on;  %axis([-1,1,-1.05,1.05]);
    title('Phase Response');
    xlabel('frequency in pi units'); ylabel('Radians/pi');
    
    figure('NumberTitle', 'off', 'Name', 'Problem 3.19 X3');
    set(gcf,'Color','white'); 
    subplot(2,1,1); plot(w/pi, realX3); grid on;
    title('Real Part');
    xlabel('frequency in pi units'); ylabel('Real');
    subplot(2,1,2); plot(w/pi, imagX3); grid on;
    title('Imaginary Part');
    xlabel('frequency in pi units'); ylabel('Imaginary');
    %% -------------------------------------------------------------------
    %%             END X's  mag ang real imag
    %% -------------------------------------------------------------------
    

      运行结果:

          采样后的序列及其谱。

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    php-fpm 进程数的设定
    git如何清除远程 __pycahce__ 文件
    使用docker-compose编写常规的lnmp容器,pdo连接mysql失败。
    composer 巨慢的解决之道
    mysql 单机多实例配置
    golang 在 Mac , Linux , Windows 下交叉编译详解
    mysql 索引优化
    【转】解决深入学习PHP的瓶颈?
    debian 系统搭建rsync+sersync实现实时同步
    docker 搭建debian+nginx+php(含composer的扩展)+mysql+mongo+redis
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8249846.html
Copyright © 2020-2023  润新知