《DSP using MATLAB》Problem 3.8
2018年元旦,他乡加班中,外面尽是些放炮的,别人的繁华与我无关。

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.8 \n\n'); banner();
%% ------------------------------------------------------------------------
n_start = -5; n_end = 30;
n = [n_start:n_end];
x = exp(j*0.1*pi*n) .* (stepseq(0, n_start, n_end)-stepseq(20, n_start, n_end)); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 x(n)')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色
subplot(2,1,1); stem(n, real(x)); title('x sequence Real Part');
xlabel('n'); ylabel('Real[x(n)]') ;
% axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(n, imag(x)); title('x sequence Imag Part');
xlabel('n'); ylabel('Imag[x(n)]');
grid on; % ----------------------------------------------------
% DTFT of x(n)
% ---------------------------------------------------- MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X] = dtft(x, n, w); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 X(w)--DTFT of x(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX); grid on;
title('Magnitude Part of X(w)');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX); grid on;
title('Angle Part of X(w)');
xlabel('frequency in \pi units'); ylabel('Radians'); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 Real and Imag of X(w)');
set(gcf,'Color','white');
subplot('2,1,1'); stem(w/pi, realX); grid on;
title('Real Part of X(w)');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); stem(w/pi, imagX); grid on;
title('Imaginary Part of X(w)');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% ----------------------------------------------------
%% Even and Odd part of X(jw)
%% ----------------------------------------------------
[XE, XO, m] = evenodd_cv(X, w/pi*500); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 XE(m)--Even of X(w)')
set(gcf,'Color',[1,1,1])
subplot(2,1,1); stem(m/500, real(XE)); title('Real Part of Even Sequence');
xlabel('m in \pi units'); ylabel('Real[XE(m)]');
%axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(m/500, imag(XE)); title('Imag Part of Even Sequence');
xlabel('m in \pi units'); ylabel('Imag[XE(m)]');
%axis([-10,10,0,1.2])
grid on figure('NumberTitle', 'off', 'Name', 'Problem 3.8 XO(m)--Odd of X(w)')
set(gcf,'Color','white')
subplot(2,1,1); stem(m/500, real(XO)); title('Real Part of Odd Sequence');
xlabel('m in \pi units'); ylabel('Real[XO(m)]');
%axis([-10,10,0,1.2])
grid on
subplot(2,1,2); stem(m/500, imag(XO)); title('Imag Part of Odd Sequence');
xlabel('m in \pi units'); ylabel('Imag[XO(m)]');
%axis([-10,10,0,1.2])
grid on % ---------------------------------------------------
% DTFT of Realx(n)
% --------------------------------------------------- MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [RX] = dtft(real(x), n, w); magRX = abs(RX); angRX = angle(RX); realRX = real(RX); imagRX = imag(RX); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 RX(w)--DTFT of Realx(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magRX); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angRX); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 Real and Imag of RX(w)');
set(gcf,'Color','white');
subplot('2,1,1'); plot(w/pi, realRX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); plot(w/pi, imagRX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); % -------------------------------------------------------
% DTFT of Imagx(n)
% ------------------------------------------------------- MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [IX] = dtft(j*imag(x), n, w); magIX = abs(IX); angIX = angle(IX); realIX = real(IX); imagIX = imag(IX); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 IX(w)--DTFT of Imagx(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magIX); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angIX); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 Real and Imag of IX(w)');
set(gcf,'Color','white');
subplot('2,1,1'); plot(w/pi, realIX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); plot(w/pi, imagIX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); % ------------------------------------------
% Verify
% ------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 3.8 RX(w) and RealXE');
set(gcf,'Color','white');
subplot('2,1,1'); plot(w/pi, realRX); grid on;
title('Real Part of RX(w)');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,1,2'); plot((m/500), real(XE)); grid on;
title('Real Part of XE(w)');
xlabel('frequency in \pi units'); ylabel('Real'); figure('NumberTitle', 'off', 'Name', 'Problem 3.8 IX(w) and ImagXO');
set(gcf,'Color','white');
subplot('2,1,1'); plot(w/pi, imagIX); grid on;
title('Imaginary Part of IX(w)');
xlabel('frequency in \pi units'); ylabel('Imaginary');
subplot('2,1,2'); plot((m/500), imag(XO)); grid on;
title('Imaginary Part of XO(w)');
xlabel('frequency in \pi units'); ylabel('Imaginary');
运行结果:
1、原始序列及其DTFT


2、序列DTFT进行共轭奇偶对称分解



3、原始序列实部和虚部的DTFT


4、对比结果
序列DTFT的共轭偶对称分量和序列实部的DTFT结果相同;

序列DTFT的共轭奇对称分量和序列虚部的DTFT结果相同;

《DSP using MATLAB》Problem 3.8的更多相关文章
- 《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- VS 2013 无法启动IIS Express Web 服务器
之前程序好好的没什么问题,可是今天一大早来到公司后打开VS2013运行Web程序,然后就弹出提示信息:无法启动IIS Express Web 服务器,思来想去昨天都好好的,今天怎么会出现如此问题呢? ...
- POJ-1511 Invitation Cards (双向单源最短路)
Description In the age of television, not many people attend theater performances. Antique Comedians ...
- 项目构建工具gradle
1.安装 https://gradle.org/install 2.构建一个项目 https://guides.gradle.org/creating-new-gradle-builds/ 3.bui ...
- JavaScript 运行机制详解:Event Loop——续
转自:http://www.ruanyifeng.com/blog/2014/10/event-loop.html 五.定时器 除了放置异步任务的事件,"任务队列"还可以放置定时事 ...
- Visual C++ 使用纪要
1.取消在查找中标记的蓝色小方块 Ctrl+Shift+F2 取消所有标记 2.出现LINK错误 : fatal error LNK1168: cannot open Debug/x.exe for ...
- jsp javabean开发模式
JSP&&JavaBean开发模式 在jsp+javabean架构中,jsp负责控制逻辑,表现逻辑,业务对象的调用 jsp+javaBean模式适合开发业务逻辑不复杂的web应用,这种 ...
- openSUSE 12.3 默认启动项
修改默认opensuse12.3的默认启动项目(grub2). vim /boot/grub2/grubenv 里面有一条: saved_entry=openSUSE 12.3 修改为saved_en ...
- zoj2112&&bzoj1901
题解: 可修改的主席树 一开始,我就按照最暴力的方法,空间nlognlogn 然后zju上面过不了,bzoj没有权限号 然后,参考了往上的论文,发现可以把初始的主席树先建好 然后,每次只需要维护修改的 ...
- pyqt(二) 创建第一个程序(helloworld)解决object has no attribute 'setCentralWidget'
1.运行Qt Creator QtCreator主界面分为了6个模式:欢迎模式.编辑模式.设计模式.Debug调试模式.项目模式和帮助模式,分别由左侧的6个图标进行切换,对应的快捷键是Ctrl + 数 ...
- re 正则
如果直接给出字符,就是精确匹配.对于特殊字符- ,在正则表达式中要用转义字符\转义. \d 一个数字, \w 任意单个字符,空白符除外(例 字母.数字或下划线 . 英 ...