《DSP using MATLAB》Problem 3.9

利用的频移性质为:

本习题代码:
%% ------------------------------------------------------------------------
%% 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的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- ScriptableObjec 的简单使用
1.ScriptableObject的创建(一): using System.Collections; using System.Collections.Generic; using UnityEng ...
- Failed to execute operation: No such file or directory(systemctl enable iptables.service)
在保存Iptables配置时:systemctl enable iptables.service 出现错误: Failed to execute operation: No such file or ...
- Greengenes Database(16S)
The Greengenes Database Release 13_5 这是16S的一个非常重要的数据库 The Greengenes Database, a public resource sin ...
- Silverlight自定义控件系列 – TreeView (4) 缩进
接下来是缩进,没有缩进的Tree怎么看都不顺眼. 首先,定义节点深度Depth(注:回叫方法暂没有代码,以后要用到): 1: /// <summary> 2: /// Using a De ...
- 加密算法(DES,AES,RSA,MD5,SHA1,Base64)比较和项目应用
加密技术通常分为两大类:"对称式"和"非对称式". 对称性加密算法:对称式加密就是加密和解密使用同一个密钥.信息接收双方都需事先知道密匙和加解密算法且其密匙是相 ...
- Java数组常用API
java.util.Arrays Arrays.asList() 数组转换成列表 String[] strArray = {"zhang", "xue", &q ...
- SSH 反向代理
SSH反向代理 被控制端没有NAT或者没有静态公网IP,把本端一台服务器映射到外网给远端SSH进来,建立SSH反向隧道. 先映射本端机器到外网 nat server 2222to22 protoco ...
- iOS UI-九宫格
第一节课: .复习 .运行App应用管理,简单界面分析 .一个应用为一个整体,直接创建一个appView然后计算frame .说明弊端,应该根据数据的个数来for循环创建 第二节课: .加载plist ...
- 我所理解的event loop
灵魂三问 JS为什么是单线程的 我们都知道,JS是单线程的语言,那为什么呢?我的理解是JS设计之初就是为了在浏览器端完成DOM操作和一些简单交互的,既然涉及到DOM操作如果是多线程就会带来复杂的同步问 ...
- dup的使用(二)
转自:http://blog.csdn.net/yeyuangen/article/details/6852682 一个进程在此存在期间,会有一些文件被打开,从而会返回一些文件描述符,从shell中运 ...