代码:

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. JavaScript高级程序设计学习笔记--函数表达式

    关于函数声明,它的一个重要特征就是函数声明提升,意思是在执行代码之间会读取函数声明,意思是在执行代码之前会先读取函数声明.这就意味着可以把函数声明放在调用它的语句 后面. sayHi(); funct ...

  2. Mysql 基础 高级查询

    在西面内容中    car  和  nation   都表示 表名 1.无论 高级查询还是简单查询   都用  select.. from..语句   from  后面 加表名  可以使一张表也可以是 ...

  3. 【leetcode】 Scramble String (hard)★

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  4. ajax+bootstrap做弹窗

    建页面,引入bootstrap弹窗 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  5. Servlet题库

    一.    填空题 Servlet中使用Session对象的步骤为:调用  HttpServletRequest.getSession()  得到Session对象,查看Session对象,在会话中保 ...

  6. ios waxpatch lua语法

    Wax Lua 使用方法 说一下 Wax 的特点,它支持你在脚本里使用任何 OC 的类,同样也支持你创建一个类. 使用一个类时你会这样使用: 1 2 NSString -- Returns the N ...

  7. 三、jQuery--Ajax基础--Ajax全接触--Ajax在JS中的应用

    Ajax的全称:Asynchronous JavaScript And XML(异步的 JavaScript 和 XML). Ajax不是某种编程语言,是一种在无需重新加载整个网页的情况下能够更新部分 ...

  8. Jquery.Datatables 结合时间段查询,daterangepicker实现Datatables表格带参数查询

      参考:http://datatables.club/example/user_share/send_extra_param.html   下载地址:http://pan.baidu.com/s/1 ...

  9. 重温WCF之数据契约中使用枚举(转载)(十一)

    转载地址:http://www.zhuli8.com/wcf/EnumMember.html 枚举类型的定义总是支持序列化的.当我们定义一个新的枚举时,不必应用DataContract特性,就可以在数 ...

  10. 以16进制打印出一块内存buff

    如下代码(支持windows与Linux)会以[16进制][每行16字节]打印出一块内存的内容: void PrintBuffer(void* pBuff, unsigned int nLen) { ...