《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- C# DataTable按指定列排序
C#提供的内置对象DataTable功能特别的强大,如果我们需要对DataTable中的某一列进行排序怎么处理呢,具体代码如下: DataTable dt = new DataTable(); dt. ...
- jsp/post中文乱码问题
在 iso-8859-1,gb2312, utf-8 以及任意一种编码格式下,英文编码格式都是一样的,每个字符占8位,而中文就麻烦了,在gb2312 下一个中文占 16位,两字节,而在utf-8 下一 ...
- 3.3 x86指令简介
计算机组成 3 指令系统体系结构 3.3 x86指令简介 x86指令种类繁多,数量庞大.在这一节我们将会学习x86指令的分类,并分析其中最为基础的一部分指令. 通常一个指令系统主要包括这几类指令.运算 ...
- 21 模块(collections,time,random,os,sys)
关于模块importfrom xxx import xxx2. Collections1. Counter 计数器2. 栈: 先进后出.队列:先进先出deque:双向队列3. defaultdict ...
- PC端,移动端分离,如何结合??
<script type="text/javascript"> function mobile_device_detect(url) { var thisOS = na ...
- git rm删除
在Git中,删除也是一个修改操作,我们实战一下,先添加一个新文件test.txt到Git并且提交: $ git add test.txt $ git commit -m "add test. ...
- UVA-818 Cutting Chains (位压缩+暴力搜索)
题目大意:一种环能打开和闭合.现在有n(1<=n<=15)个编号为1~n的环错综复杂的连接着,要打开一些环重新连接使这n个环能构成一条链,问最少需要打开几次环可达到目的? 题目分析:用二进 ...
- ** exception error: no match of right hand side value
错误发生的情况是模式匹配失败.对于badmatch异常,很难找到单一的原因,但经常性的原因是你无意间尝试绑定已绑定过的变量.
- 使用 PM2 管理nodejs进程
pm2 是一个带有负载均衡功能的Node应用的进程管理器. 当你要把你的独立代码利用全部的服务器上的所有CPU,并保证进程永远都活着,0秒的重载, PM2是完美的. 它非常适合IaaS结构,但不要把它 ...
- 如何使用Java Enum
简单的用法:JavaEnum简单的用法一般用于代表一组常用常量,可用来代表一类相同类型的常量值.如: 性别: public enum SexEnum { male, female; } 颜色: pub ...