利用的频移性质为:

本习题代码:

%% ------------------------------------------------------------------------
%% 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. robotframework安装与配置--学习第一天

    刚刚入职公司,之前学的是Java+selenium自动化测试,但公司要求使用robot framework,所以找了些资料学习.刚开始觉得为什么不用java.python等开发语言+selenium做 ...

  2. PHP访问Oracle数据库

    说明:Oracle数据库帐号:sticOracle数据库密码:sticOracle数据库实例:orclOracle数据库表:UserInfoOracle表的列:ID,Name 不处理异常的代码如下:/ ...

  3. codeforces 555a//Case of Matryoshkas// Codeforces Round #310(Div. 1)

    题意:1-n的数字,大的在小的后面,以这种规则已经形成的几个串,现在要转为一个串,可用的操作是在末尾拆或添加,问要操作几次? 模拟了很久还是失败,看题解才知道是数学.看来这种只要结果的题,模拟很不合算 ...

  4. 页面title改变浏览器兼容性问题

    前一阵子客户在界面上改了下小小的需求,需要点不同的文章title显示不同的模块名称(之前没有区分,统一叫新闻图片),很简单的一个需求但是测试的时候并没有注意到不兼容IE7和IE8.在客户那被尴尬的发现 ...

  5. python-day47--pymysql模块

    一.安装导入 #安装 pip3 install pymysql 二.使用 1 .基本使用 import pymysql # 链接,拿到游标 conn=pymysql.connect(host='loc ...

  6. POJ-1160 Post Office (DP+四边形不等式优化)

    题目大意:有v个村庄成直线排列,要建设p个邮局,为了使每一个村庄到离它最近的邮局的距离之和最小,应该怎样分配邮局的建设,输出最小距离和. 题目分析:定义状态dp(i,j)表示建设 i 个邮局最远覆盖到 ...

  7. char,varchar与text类型的区别和选用

    (1)char: 它是定长格式的,但是长度范围是0~255. 当你想要储存一个长度不足255的字符时,mysql会用空格来填充剩下的字符.因此在读取数据时,char类型的数据要进行处理,把后面的空格去 ...

  8. arc路径例子-磊哥

       <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    & ...

  9. ECC算法整理纪要

    初始ECC算法 1.用户A 密钥生成 (1):用随机数发生器产生随机数k∈[1,n-1]: (2):计算椭圆曲线点PA=[k]G,为公钥,k为用户A私钥: 2. 用户B加密算法及流程 设需要发送的消息 ...

  10. httpclient 连接保持

    http连接重用 从一个主机向另外一个建立连接的过程时相当复杂的,而且包含了两个终端之间的很多包的交换,它是相当费时的. 连接握手的开销是很重要的,特别是对小量的HTTP报文. 如果打开的连接被重用来 ...