频率采样定理是这样的:

由上述定理可知,一个有限长序列(假设为N)的DTFT等间隔采样,采样数至少大于等于N。

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.6 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % --------------------------------------------------
% 1 x(n) = n + 1 n=[ 0:49]
% = 100-n n=[50:99]
% = 0 otherwise
% --------------------------------------------------
L = 50; n = [0:L-1]; N = 100; %k1 = [0 : N-1]; % wave parameters xn_1 = [n+1, 100-(n+50)]; % length 100
xn_2 = [xn_1, zeros(1,100)]; % padding 100 zeros figure('NumberTitle', 'off', 'Name', 'P5.6 xn_1 and xn_2')
set(gcf,'Color','white');
subplot(2,1,1); stem([0:N-1], xn_1);
xlabel('n'); ylabel('x(n)');
title('xn1 sequence'); grid on;
subplot(2,1,2); stem([0:length(xn_2)-1], xn_2);
xlabel('n'); ylabel('x(n)');
title('xn2 sequence'); grid on; % -------------------------------------------------------------
% X(jw), DTFT of x(n)
% -------------------------------------------------------------
MM1 = 500;
%k = [-MM : MM]; % [-pi, pi]
%k = [0:MM]; % [0, pi]
%w = (2*pi/MM) * k; [X1, w1] = dtft1(xn_1, [0:N-1], MM1); %[X] = dtft(xn_1, [0:N-1], w); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); figure('NumberTitle', 'off', 'Name', 'Problem 5.6 DTFT X(jw) of x(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w1/pi, magX1); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w1/pi, angX1); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Phase'); figure('NumberTitle', 'off', 'Name', 'Problem 5.6 Real and Imag of X(jw)');
set(gcf,'Color','white');
subplot('2,1,1'); plot(w1/pi, realX1); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); plot(w1/pi, imagX1); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% -----------------------------------------------------------------------
%% 10-point frequency sample of X(w), DTFT of xn1 sequence
%% then IDFS to get y1(n)
%% -----------------------------------------------------------------------
y1 = real( idfs( X1(1:100:1000), 10) ); figure('NumberTitle', 'off', 'Name', 'Problem 5.6 10-point IDFS X(jw)');
set(gcf,'Color','white');
%subplot(2,1,1);
stem([0:9], y1); grid on;
title('y1(n)');
xlabel('n'); ylabel('y1'); %% -----------------------------------------------------------------------
%% 200-point frequency sample of X(w), DTFT of xn1 sequence
%% then IDFS to get y2(n)
%% -----------------------------------------------------------------------
y2 = real( idfs(X1(1:5:1000), 200) );
figure('NumberTitle', 'off', 'Name', 'Problem 5.6 200-point IDFS X(jw)');
set(gcf,'Color','white');
%subplot(2,1,1);
stem([0:199], y2); grid on;
title('y2(n)');
xlabel('n'); ylabel('y2'); %% -----------------------------------------------------------------------
%% 100-point frequency sample of X(w), DTFT of xn1 sequence
%% then IDFS to get y3(n)
%% -----------------------------------------------------------------------
y3 = real( idfs(X1(1:10:1000), 100) );
figure('NumberTitle', 'off', 'Name', 'Problem 5.6 100-point IDFS X(jw)');
set(gcf,'Color','white');
%subplot(2,1,1);
stem([0:99], y3); grid on;
title('y3(n)');
xlabel('n'); ylabel('y3');

  运行结果:

原始序列,长度为N=200,但是只有前100个元素不为零,可以看成长度为100的序列末尾补了100个零。

[-2π,2π]范围内的DTFT

[0,2π]范围内的DTFT

DTFT进行10等分采样,然后IDFS变换得到序列y1

DTFT进行200等分采样,然后IDFS变换得到序列y2

DTFT进行100等分采样,然后IDFS变换得到序列y3

由上图可知,y3(100等分DTFT再逆变换)与原始序列的非零部分相同,y2(200等分DTFT再逆变换)与原始序列完全相同,y1有畸变。

《DSP using MATLAB》Problem 5.6的更多相关文章

  1. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.13

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. 1-4Controller之Middleware

    1.注册中间件: 新建中间件文件:Activity <?php namespace App\Http\Middleware; use Closure; class Activity{ publi ...

  2. day18 类与类之间的关系

    今日所学内容: 1.类与类之间的关系 2.self 到底是谁? 3. 特殊成员 : 1.类与类之间的关系 在我们的世界中事物和事物之前总会有一些联系 在面向对象中,类与类之间也可以产生相关的联系 1) ...

  3. VSTO:使用C#开发Excel、Word【8】

    office加载项Office开发中使用的第二种模式是加载项模式.本书涵盖了几种Office加载项.其中包括Outlook的VSTO加载项,Excel和Word的COM加载项以及Excel的自动化加载 ...

  4. UNICODE_STRING(用户模式 内核模式)

    UNICODE_STRING结构: typedef struct  _UNICODE_STRING { USHORT Length;                                   ...

  5. centos7 安装jdk8 bash脚本 并配置环境变量

    #!/bin/bash #安装java脚本 if type -p java; then echo 'java已安装.' exit else echo '开始安装java...' wget --no-c ...

  6. 查看电脑安装的JDK版本

    1.输入java -d32 -version,若出现如下界面则是32位 2.java -d64 -version,因为是32位的,所以结果如下

  7. php优秀框架codeigniter学习系列——安装,配置

    下载 可在官网下载,我使用的是CodeIgniter-3.1.7. 目录 打开程序目录,可看到目录结构. 我这里做一点小的修改,新建了一个 index 目录,将 index.php 和一些静态文件放入 ...

  8. $_SERVER['URI']

    WordPress通过301重定向实现非首先域(非www)跳转向本来是一个很简单事情,由于没弄清楚$_SERVER['HTTP_X_REWRITE_URL'] 和$_SERVER['REQUEST_U ...

  9. jquery.datatables设置列隐藏的方法

    项目需要根据权限设置表格(使用Juqery.datatables,版本:1.10.16)某列显示或隐藏,百度后有两种实现方法: 1.在columns中设置: columns:[{data:" ...

  10. centos安装htop

    在 Linux 系统中,top 命令用来显示系统中正在运行的进程的实时状态,它显示了一些非常有用的信息,比如 CPU 利用情况.内存消耗情况,以及每个进程情况等.但是,你知道吗?还有另外一个命令行工具 ...