《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- fedora修改主目录文件名为英文
在gnome-terminal里面能够显示中文的,但是在文本终端里面中文都是不能显示的,是一个小小的正方形.因此可以只把主目录文件名换成英文的,方便文本终端命令输入,而其他的一些地方还是 ...
- 字王谈M1字形与个人云字库
字王谈M1字形与个人云字库 最近在忙网络项目,字库其实也没完全搁下,只是没有时间细大理,这些文字idea,来自近日和大梁先生的QQ聊天,虽然口语化很重,但觉得有些价值,作为blog发了 ----- ...
- springcloud6---Eureka的配置:
Eureka的配置: 自我保护:表示eureka进入了自我保护模式,eureka启动的时候会从高可用其他节点获取注册表信息,eureka client会每30秒发送心跳,如果eureka server ...
- BootStrap一页通(样式+组件+插件)
bootstrap是一种前端框架,实现美观的页面效果.使用BootStrap的前期工作(注意顺序): <!DOCTYPT html>:因为Bootstrap用到了h5的特性,所以需要此步. ...
- bzoj3629 / P4397 [JLOI2014]聪明的燕姿
P4397 [JLOI2014]聪明的燕姿 根据唯一分解定理 $n=q_{1}^{p_{1}}*q_{2}^{p_{2}}*q_{3}^{p_{3}}*......*q_{m}^{p_{m}}$ 而$ ...
- POI之Excel导出
1,在maven的pom文件中添加依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId& ...
- 第7章 调试和错误处理 7.1.1 VS中的调试
VS有一个输出窗口,调用方法是 需要注意的是,这个窗口有两个模式,使用其中的下拉列表就可以选择这些模式.可以在Build和Debug模式之间切换.Build和Debug模式分别显示编译和运行期间的信息 ...
- Asynchronous Programming Model (APM)异步编程模型
https://msdn.microsoft.com/zh-cn/library/ms228963(v=vs.110).aspx 一.概念 An asynchronous operation that ...
- [kata]数值内3和5的倍数的总和求解
这个题是这样的,方法参数接受一个数值,以3,5为基数,返回小于这个参数的3,5的倍数,加上3,5本身总和. 朋友段帅说头疼,估计是天气原因吧,好起来吧,还得战斗呢.
- UVa 10328 Coin Toss(Java大数+递推)
https://vjudge.net/problem/UVA-10328 题意: 有H和T两个字符,现在要排成n位的字符串,求至少有k个字符连续的方案数. 思路:这道题目和ZOJ3747是差不多的,具 ...