代码:

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. Solr安装过程

    Solr安装过程 下载相关资料 solr 4.2.0 http://lucene.apache.org/solr/ 期间安装过 solr 4.3.0 很可惜没有配置成功 apache-tomcat-7 ...

  2. 35. Search Insert Position

    题目: Given a sorted array and a target value, return the index if the target is found. If not, return ...

  3. ios wax热更新之安装wax(xcode7.3.1)

    通过Finder浏览到你保存该项目的文件夹.创建三个新的文件夹:wax.scripts和Classes. 第一:首先,下载源代码的压缩包.Wax放在GitHub上(https://github.com ...

  4. 单击双击手势(UITapGestureRecognizer)

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  5. Linq查询

    //Linq查询 List<A1> a1 = new List<A1>(); a1.Add(, Name = , Gender = true }); a1.Add(, Name ...

  6. 转:不再以讹传讹,GET和POST的真正区别

    如果有人问你,GET和POST,有什么区别?你会如何回答? 我的经历 前几天有人问我这个问题.我说GET是用于获取数据的,POST,一般用于将数据发给服务器之用. 这个答案好像并不是他想要的.于是他继 ...

  7. Clr Via C#读书笔记---CLR寄宿和应用程序域

    #1 CLR寄宿: 开发CLR时,Microsoft实际是将他实现成包含在一个dll中的COM服务器.Microsoft为CLR定义了一个标准的COM接口,并为该接口和COM服务器分配了GUID.安装 ...

  8. 闲谈SQL脚本优化

    摘要: 闲来无事,便想寻找大师级别优化SQL脚本案例,也算是读后留点笔记,摘录内容都会链接到所参考网址,如有冒犯,还望博主见谅:有些文章只有多动手多动脑才能理解其中的意思,看了需要实际操作,才不枉大师 ...

  9. Visual Studio 2015的Web扩展包

    过去几年,Visual Studio扩展功能生态系统得到了蓬勃发展,社区贡献出了大量优秀的扩展,其中也包括大量针对Web开发的扩展.但是很多时候,感觉寻找.安装.更新好 几个扩展,总显得比较麻烦.如果 ...

  10. a个人经验总结2

    金额 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8& ...