《DSP using MATLAB》Problem 3.2
1、用x1序列的DTFT来表示x2序列的DTFT
2、代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.2 \n\n'); banner();
%% ------------------------------------------------------------------------ % ----------------------------------
% x1(n)
% ----------------------------------
n1_start = 0; n1_end = 3;
n1 = [n1_start : n1_end]; x1 = [1, 2, 2, 1]; figure('NumberTitle', 'off', 'Name', 'Problem 3.2 x1(n)');
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x1');
title('x1(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X1] = dtft(x1, n1, w); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 DTFT of x1(n)');;
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'); X1_chk = (1+exp(-j*w*4)) .* X1;
magX1_chk = abs(X1_chk); angX1_chk = angle(X1_chk); realX1_chk = real(X1_chk); imagX1_chk = imag(X1_chk); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 X2(w) obtained by formular with X1(w)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX1_chk); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX1_chk); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % -------------------------------------
% x2(n)
% -------------------------------------
[x2, n2] = sigshift(x1, n1, 4); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 x2(n)');
set(gcf,'Color','white');
stem(n2, x2);
xlabel('n'); ylabel('x2');
title('x2(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X2] = dtft(x2, n2, w); magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 DTFT of x2(n)');;
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'); % -------------------------------------
% x3(n)
% -------------------------------------
[x3, n3] = sigadd(x1, n1, x2, n2); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 x3(n)');
set(gcf,'Color','white');
stem(n3, x3);
xlabel('n'); ylabel('x3');
title('x3(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X3] = dtft(x3, n3, w); magX3 = abs(X3); angX3 = angle(X3); realX3 = real(X3); imagX3 = imag(X3); figure('NumberTitle', 'off', 'Name', 'Problem 3.2 DTFT of x3(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX3); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX3); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians');
运行结果:
通过第1小题得到的公式计算x2序列的谱,如下:
可看出,第1小题公式计算的结果,和直接将序列通过DTFT定义得到结果是相同的。
《DSP using MATLAB》Problem 3.2的更多相关文章
- 《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- cocos代码研究(21)Widget子类Text,TextAtlas,TextBMFont学习笔记
理论基础 Text类又称ttf格式文本,可以用ttf文件或者系统自带字体,支持文字多,但是ttf文件格式体积大,渲染速度慢: TextBMFont类又称fnt格式文本,纹理创建,根据纹理上有的文字来显 ...
- hdu5188 01 背包
这题说的是给了n道题每道题用时ti分钟,需要在Li 时间或者之后完成,得分为vi, 我们 首先必须要能过完成,尽量让L-t小的放在前面. 然后采用背包去做 #include <iostream& ...
- ng-深度学习-课程笔记-5: 深层神经网络(Week4)
1 深度L层神经网络( Deep L-layer Neural network ) 针对具体问题很难判断需要几层的网络,所以先试试逻辑回归是比较合理的做法,然后再试试单隐层,把隐层数量当作一个超参数, ...
- 图解Kerberos认证工作原理
本文是我在看了这篇英文说明之后的总结 https://technet.microsoft.com/zh-cn/library/cc961976.aspx 是总结,不是翻译,所以是我看后按自己的理解写的 ...
- centos6.5搭建svn
检查已经安装版本 rpm -qa subversion如果存在旧版本,卸载yum remove subversion 安装svn yum install subversion 验证是否安装成功 sv ...
- Java实现文本创建、删除、编辑内容
Java实现文本创建.删除.编辑内容 1,创建文本代码: //创建文件并追加内容 public static void writeContentToTxt(StringBuffer Content,F ...
- 这才是官方的tapable中文文档
起因 搜索引擎搜索tapable中文文档,你会看见各种翻译,点进去一看,确实是官方的文档翻译过来的,但是webpack的文档确实还有很多需要改进的地方,既然是开源的为什么不去github上的tapab ...
- 20145201李子璇 《网络对抗》 Web安全基础实践
1.实验后回答问题 (1)SQL注入攻击原理,如何防御 原理:通过构建特殊的输入作为参数传入web应用程序.即把SQL命令注入到Web表单的输入域或页面请求的查询字符串,和之前已经设定好的查询语句构成 ...
- 如何创建.babelrc文件?
方法一: 根目录下,创建 .babelrc. 文件名就可以了! 方法二: git进入根目录,输入 type>.babelrc ,回车即可!
- zabbix中监控某个进程的shell脚本
#!/bin/sh ret_ok= ret_warn= ret_critical= ret_unknown= info_count=`ps -aux | awk 'BEGIN {cnt=0} /[^- ...