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. php时区设置 warning: strtotime(): It is not safe to rely on the system's timezone settings

    warning: strtotime(): It is not safe to rely on the system's timezone settings warning: strtotime(): ...

  2. DataGridView1

    for (int i = 0; i < DataGridView1.SelectedRows.Count; i++)    { //第i行第一列 String ai1= DataGridView ...

  3. ORACLE COMMENTON 使用

    oracle中用comment on命令给表或字段加以说明,语法如下:COMMENT ON  { TABLE [ schema. ]    { table | view }  | COLUMN [ s ...

  4. poj1664 放苹果(DPorDFS)&&系列突破(整数划分)

    poj1664放苹果 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33661   Accepted: 20824 Desc ...

  5. OC 类对象和类加载

    //------------------------Persion类----------------------------// 1 #import "Person.h" @imp ...

  6. RpcContext

    RpcContext内部有一个ThreadLocal变量,它是作为ThreadLocalMap的key,表明每个线程有一个RpcContext. public class RpcContext { p ...

  7. Python的数据类型1数值和字符串

    Python的交互器 在讲这个之前,我要先讲一下python的交互器,之后讲解代码(除了做简单项目)都在交互器上进行,这样可能比较直接一些,有利于刚接触python的人理解代码 python在命令行自 ...

  8. idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space

    idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space ...

  9. Sql server函数的学习2(游标函数、日期函数、字符串操纵函数)

    一.游标函数与变量 游标可以处理多行数据,在过程循环中一次访问一行.和基于集合的高效操作相比,这个功能对系统资源的消耗更大. 可以用一个函数和两个全局变量来管理游标操作 1.CURSOR_STATUS ...

  10. Python & PyCharm & Django 搭建web开发环境

    一.安装软件 1.安装 Python 2.7.PyCharm.pip(Python包管理工具).Django ( pip install Django) 二.部署 1.PyCharm 新建Django ...