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的更多相关文章

  1. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.13

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. select exists 的应用一例

    当遇到多层exists的时候,事情就变得开始复杂了.我们来看看这个例子吧 假设有三张表 选课表:学号.课程号 学生表:学号.姓名 课程表:课程号.课程名 请选出选了所有课程的学生 SELECT 姓名 ...

  2. spfa毒瘤算法

    终于知道怎么卡spfa(不优化)这一毒瘤算法了 下面就是造数据代码,点数才1e5,边数379980 随便测了一组数据: count: 831841219(入队次数) 68917.096 ms(足够t到 ...

  3. Educational Codeforces Round 47 (Rated for Div. 2)G. Allowed Letters 网络流

    题意:给你一个字符串,和每个位置可能的字符(没有就可以放任意字符)要求一个排列使得每个位置的字符在可能的字符中,求字典序最小的那个 题解:很容易判断有没有解,建6个点表示从a-f,和源点连边,容量为原 ...

  4. 使用Div + CSS布局页面

    在设计网页时,能够控制好各个模块在页面中的位置是非常关键的.本章将讲解利用Div+CSS对页面元素进行定位的方法. Div是HTML中指定的专门用于布局设计的容器对象 Div是CSS布局的核心对象. ...

  5. page上BeanId与ActionType中的ParameterId

    今天遇到一件有意思的异常. 一个基于EO的VO在页面加载进来之后就CreateRow了一行数据,主键HeaderId也相应的插入了值,但是在保存的时候,老是报HeaderId不能为空的异常. 经查,页 ...

  6. EBS OAF开发中的错误/异常处理(ErrorHandling) (转)

    原文地址 EBS OAF开发中的错误/异常处理(ErrorHandling) EBS OAF开发中的错误/异常处理(ErrorHandling) (版权声明,本人原创或者翻译的文章如需转载,如转载用于 ...

  7. JSP EL简介

    JSP EL简介:1.语法:    ${expression} 2.[ ]与.运算符    EL 提供“.“和“[ ]“两种运算符来存取数据.     当要存取的属性名称中包含一些特殊字符,如.或?等 ...

  8. Eclipse重命名项目名后如何彻底修改工程名

    背景:在Eclipse中当我们修改了一个Web项目名称后,在再次运行该项目,发现使用新的名称无法正常的浏览,而用旧的名称去可以 解决方案: 1:修改该项目目录下:.project文件 <?xml ...

  9. quartz---(1)

    Quartz Quartz是什么? 简单的一些例子 Quartz是什么 简单的认为Quartz是是一个定时器. 1.1. 下载 http://www.quartz-scheduler.org/down ...

  10. OC 复合

    在Objective-C中复合是通过包含作为实例变量的对象指针实现的 严格来说,只有对象间的组合才叫复合 --------------------Car.h---------------------- ...