代码:

x = [1, 1, 1, 1]; N = 4;
X_DFT = dft(x,N); % DFT of x(n) magX_DFT = abs(X_DFT), phaX_DFT = angle(X_DFT)*180/pi; realX_DFT = real(X_DFT); imagX_DFT = imag(X_DFT);
angX_DFT = angle(X_DFT); n = 0:(N - 1);
k = 0:1000; w = (pi/500)*k; % [0,2pi] axis divided into 501 points.
%k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points.
X_DTFT = x * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x(n) magX_DTFT = abs(X_DTFT); angX_DTFT = angle(X_DTFT); realX_DTFT = real(X_DTFT); imagX_DTFT = imag(X_DTFT); figure('NumberTitle', 'off', 'Name', 'Exameple5.6 x sequence')
set(gcf,'Color','white');
stem(n,x); title('x sequence'); axis([0,4,-0.5,1.5]);
xlabel('n'); ylabel('x(n)'); grid on; %% --------------------------------------------------------------
%% START X_DTFT's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X_DTFT its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX_DTFT); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X\_DTFT|');
subplot(2,2,3); plot(w/pi, angX_DTFT*180/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Degrees'); %axis([-200,200,0,2]); subplot('2,2,2'); plot(w/pi, realX_DTFT); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX_DTFT); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X_DTFT's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START X_DFT's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Example5.6 X_DFT its Magnitude and Angle');
set(gcf,'Color','white');
subplot(2,1,1); stem(n,magX_DFT); hold on; plot(2*w/pi,magX_DTFT,'--'); hold off;
grid on; axis([-0.5,4.2,-1,5]);
title('Magnitude Part of the DFT: N = 4');
xlabel('k'); ylabel('Magnitude |X\_DFT|');
subplot(2,1,2); stem(n, phaX_DFT); hold on; plot(2*w/pi,angX_DTFT*180/pi,'--'); hold off;
grid on; axis([-0.5,4.2,-200,200]);
title('Angle Part of the DFT: N = 4');
xlabel('k'); ylabel('Degrees'); %axis([-200,200,0,2]); %subplot('2,2,2'); stem(n, realX_DFT); grid on;
%title('Real Part');
%xlabel('frequency in \pi units'); ylabel('Real');
%subplot('2,2,4'); stem(n, imagX_DFT); grid on;
%title('Imaginary Part');
%xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X_DFT's mag ang real imag
%% --------------------------------------------------------------

  运行结果:

《DSP using MATLAB》示例Example5.6的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  6. DSP using MATLAB 示例Example3.17

  7. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. JS中数组Array的用法示例介绍 (转)

    new Array() new Array(len) new Array([item0,[item1,[item2,...]]] 使用数组对象的方法: var objArray=new Array() ...

  2. rsync.conf详解

    1.在服务端编辑配置文件 [root@game_intf ~]# more /etc/rsyncd.conf port=8730 log file=/var/log/rsync.log pid fil ...

  3. IOS- Run Loops

    Run Loops Run loops是线程相关的的基础框架的一部分.一个run loop就是一个事件处理的循环,用来不停的调度工作以及处理输入事件.使用run loop的目的是让你的线程在有工作的时 ...

  4. NodeVisitor的使用-遍历Geode节点并在它与父节点之间添加一个LOD节点

    #include <osg\NodeVisitor>#include <osg\MatrixTransform>#include <osg\PagedLOD>#in ...

  5. ubuntu 添加环境变量

    转自:http://hi.baidu.com/mario05/item/02b6d60ff7371136a2332a48 Ubuntu Linux系统环境变量配置文件:/etc/profile : 在 ...

  6. Mysql复制语句

    可分为三组(Group):用于Master ,用于Slave,用于任何复制服务.

  7. android 开发赚钱

    原 android 开发赚钱 谁带我去看看世界 发布时间: 2015/06/09 12:05 阅读: 1589 收藏: 37 点赞: 2 评论: 5 开发android也有一年左右了,利用业余时间陆续 ...

  8. hdu1018(数位)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 题意:求n!的数位(即n!有多少位): 思路:对于一个数x,它的数位ans=log10(x): ...

  9. highcharts的简单使用

    在使用过的图表js插件中,个人认为还是highcharts最好,无论从兼容性,渲染速度,甚至是文档详细上来说,都一直觉得highcharts更胜一筹.现在花点时间做一下简单的总结,比如从一个矩形图开始 ...

  10. Jquery.Datatables 基本设置的中文注解

    $(document).ready(function() { $('#example').dataTable({ "sScrollX": "100%", //表 ...