利用的频移性质为:

本习题代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.9 \n\n'); banner();
%% ------------------------------------------------------------------------ % -----------------------------------------------------------
% Rectangle Window sequence, and its DTFT
% -----------------------------------------------------------
%M = 5;
%M = 15;
%M = 25;
M = 100; n1_start = 0; n1_end = M;
n1 = [n1_start : n1_end - 1]; x1 = ones(1, length(n1)); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 x1(n) Rectangle, M = %d',M));
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x1');
title(sprintf('x1(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X1] = dtft(x1, n1, w); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 DTFT of Rm(n), M = %d', M));
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX1); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX1); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 Real and Imag of X1(w), M = %d', M));
set(gcf,'Color','white');
subplot('2,1,1'); plot(w/pi, realX1); grid on;
title('Real Part of X1(w)');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); plot(w/pi, imagX1); grid on;
title('Imaginary Part of X1(w)');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% ----------------------------------------------------------------
%% x(n)=cos(w0*n)Rm(n), and its DTFT
%% ----------------------------------------------------------------
n2 = n1;
w0 = 0.5 * pi; x2 = cos(w0*n2) .* x1;
%x2 = exp(j*w0*n2) .* x1; figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 x2(n), M = %d', M));
set(gcf,'Color','white');
stem(n2, x2);
xlabel('n2'); ylabel('x2');
title(sprintf('x1(n)*Rm(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X2] = dtft(x2, n2, w); magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 DTFT of x2(n), M = %d', M));
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX2); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX2); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.9 Real and Imag of X2(w), M = %d', M));
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realX2); grid on;
title('Real Part of X2(w)');
xlabel('frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagX2); grid on;
title('Imaginary Part of X2(w)');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% Direct equation
%% --------------------------------------------------------------
Real_X_direct = 0.5 * cos( (w/pi-w0) * (M-1) / 2) * ( sin( (w/pi-w0)*M/2 ) / sin( (w/pi-w0)/2 ) ) + 0.5 * cos( (w/pi+w0) * (M-1) / 2) * ( sin( (w/pi-(2*pi-w0))*M/2 ) / sin( (w/pi-(2*pi-w0))/2) ); check = sum(abs(realX2)-abs(Real_X_direct)) figure('NumberTitle', 'off', 'Name', 'Problem 3.9 Direct')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色
plot(w/pi, Real_X_direct); title('Real Part obtained by direct equation');
xlabel('n'); ylabel('Real[x(n)]') ;
grid on;

  运行结果:

1、方波窗序列,本题中正弦序列,以及各自DTFT;

2、谱的实部和虚部;

因为ω0=0.5π,根据频移性质,相当于沿着ω轴谱搬移了0.5π(注意到DTFT是以2π为周期的,图中显示的是[-π,π])。

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

  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. Confluence 6 嵌套用户组的备注

    潜在的性能影响.启用嵌套用户组可能会减慢用户查找的速度. 在 LDAP 中定义嵌套用户组.在 LDAP 中,一个嵌套用户组是 DN (Distinguished Name)的子用户组,这个字用户组将会 ...

  2. CodeForces 558B

    Description Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make ...

  3. UVA-12186 Another Crisis (树状DP)

    题目大意:一家工厂,一个老板(编号为0),n个工人(编号1~n),其中,有的工人是中层领导,管辖一部分其他工人.现在大家要签署一份加薪申请书,但是按照规定不能越级上访,所以只能通过一层层的中间领导传到 ...

  4. WinForm窗体自适应分辨率

    我们自己编写程序的界面,会遇到各种屏幕分辨率,只有自适应才能显的美观.实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置和大小,当窗体改变比例时,其控件的位置和大小也按此比例变化即可.因 ...

  5. idea中使用gradle

    idea中使用gradle gradle下载 gradle下载地址:https://services.gradle.org/distributions/ 这里假设下载的是4.6版本的,如下: 笔者下载 ...

  6. Python中变量、赋值、浅拷贝、深拷贝

    https://www.cnblogs.com/LetMe/p/6724555.html 在理解浅拷贝和深拷贝之前,首先要理解学习一下变量在Python中是怎样存储的: 变量的类型是分值引用与地址引用 ...

  7. snagit12个人爱好

  8. C#winform窗体如何通过windowApi的FindWindow函数获取窗体句柄

    在同一个程序里,传统方式是通过this来设置当前窗体的最大化.最小化等操作, 那么怎样通过窗体句柄来设置窗体的最大化.最小化呢? 1.界面布局 通过this设置窗体最大化: name:btnWindo ...

  9. jsp jsp标签

    JSP标签页称为Jsp Action(JSP动作元素),用于在Jsp页面中提供业务逻辑功能,避免在Jsp页面中直接编写java代码,造成jsp页面难以维护. jsp常用标签 jsp:include标签 ...

  10. java 继承 初始化顺序

    面向对象三大特性: 封装,继承,多态 java 继承初始化顺序 先初始化父类对象, 在父类对象中先初始化父类属性,再初始化父类的构造方法,然后初始化子类对象,初始化子类对象的属性,初始化子类的构造方法 ...