zoukankan      html  css  js  c++  java
  • 《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、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    构造函数模式知识的扩展
    JavaScript 创建对象之单例、工厂、构造函数模式
    javaScript 计算两个日期的天数相差
    类似购物车循环判断方法
    spring的@Transactional注解详细用法
    String.getBytes()方法中的中文编码问题(转)
    spring 定时任务的 执行时间设置规则-----看完这篇就懂了
    为什么说Redis是单线程的?
    你应该知道的 RPC 原理
    关系型数据库与NoSQL的对比
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/8249846.html
Copyright © 2011-2022 走看看