代码:

n = [0:1:99]; x = cos(0.48*pi*n) + cos(0.52*pi*n);
n1 = [0:1:9]; y1 = x(1:1:10); % N = 10 figure('NumberTitle', 'off', 'Name', 'Exameple5.8 x sequence')
set(gcf,'Color','white');
subplot(3,1,1); stem(n1,y1); title('signal x(n), 0<= n <=9, N = 10'); axis([0,10,-2.5,2.5]);
xlabel('n'); ylabel('x(n)'); grid on; Y1_DFT = dft(y1,10); % DFT of y1 magY1_DFT = abs(Y1_DFT(1:1:6));
%magY1_DFT = abs(Y1_DFT);
%phaY1_DFT = angle(Y1_DFT)*180/pi % degrees
phaY1_DFT = angle(Y1_DFT(1:1:6))*180/pi % degrees
%realX_DFT = real(X_DFT); imagX_DFT = imag(X_DFT);
%angX_DFT = angle(X_DFT); % radias k1 = 0:1:5; w1 = 2*pi/10*k1; % [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);
subplot(3,1,2); stem(w1/pi,magY1_DFT); title('Samples of DTFT Magnitude, Not Enough'); %axis([0,N,-0.5,1.5]);
xlabel('frequency in \pi units');
%ylabel('x(n)');
grid on;
subplot(3,1,3); stem(w1/pi,phaY1_DFT); title('Samples of DTFT Phase, Not Enough'); %axis([0,N,-0.5,1.5]);
xlabel('frequency in \pi units');
%ylabel('x(n)');
grid on; %% ------------------------------------------------------
%% zero-padding coperation, Append 90 zeros
%% To obtain a dense spectrum
%% ------------------------------------------------------
n2 = [0:1:99]; y2 = [x(1:1:10) zeros(1,90)]; % zero-padding, N = 100 figure('NumberTitle', 'off', 'Name', 'Exameple5.8 x sequence')
set(gcf,'Color','white');
subplot(2,1,1); stem(n2,y2); title('signal x(n), 0<= n <=9 + 90 zeros, N = 100'); axis([0,100,-2.5,2.5]);
xlabel('n'); ylabel('x(n)'); grid on; Y2_DFT = dft(y2,100); % DFT of y2 magY2_DFT = abs(Y2_DFT(1:1:51));
phaY2_DFT = angle(Y2_DFT)*180/pi % degrees k2 = 0:1:50; w2 = (2*pi/100)*k2; % [0,2pi] axis divided into 501 points.
subplot(2,1,2); stem(w2/pi,magY2_DFT); hold on; plot(w2/pi,magY2_DFT,'--r');
title('DTFT Magnitude'); axis([0,1,0,10.5]); hold off;
xlabel('frequency in \pi units');
%ylabel('x(n)');
grid on; %% -----------------------------------------------------------
%% Exameple5.8b take first 100 samples of x(n)
%% determine the DTFT
%% -----------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Exameple5.8b ')
set(gcf,'Color','white');
subplot(2,1,1); stem(n,x); axis([0,100,-2.5,2.5]);
title('signal x(n), 0 <= n <= 99, N = 100'); xlabel('n'); grid on; X = dft(x,100); magX = abs(X(1:1:51));
k = 0:1:50; w = 2*pi/100*k;
subplot(2,1,2); plot(w/pi, magX); title('DTFT Magnitude');
xlabel('frequency in \pi units'); axis([0,1,0,60]); grid on;
%% -----------------------------------------------------------
%% END Exameple5.8b
%% -----------------------------------------------------------

  结果:

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

  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. 12.3 Arithmetic-software-

    一.流程图: 二.软件功能: 分为混合模式和单则模式,混合模式生成指定题数的任意四则混合运算,数字是1-10之间随机:单则模式是生成指定题数的加减乘除中指定的某一则运算,数字是1-10之间随机. 用户 ...

  2. Hibernate的关联映射关系

    一:多对一 <many-to-one 1.name:当前类的属性名(关联映射的类) 2.column:属性多对应的类的对应的表的外键(连接条件) 3.class:属性所对应的类的权限定名 4.n ...

  3. ubuntu14.04 安装pip

    参考链接: 1.http://www.liquidweb.com/kb/how-to-install-pip-on-ubuntu-14-04-lts/ 2.http://idroot.net/tuto ...

  4. sql 的实用函数(包含日期函数、截取字符串函数)

    CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用不同的格式显示日期/时间数据. 语法 CONVERT(data_type(length),data_to_b ...

  5. Windows操作系统待整理

    12. 2001年10月25日Windows XP发布,Windows XP是基于Windows 2000代码的产品,同时拥有一个新的用户图形界面(叫做月神Luna),它包括了一些细微的修改.集成了防 ...

  6. 硬盘下安装Ghost系统简易教程

    硬盘安装器下载:https://eyun.baidu.com/s/3c2NvcvI 密码:Cv7F 使用本方法可在没有光驱.光盘.启动U盘等任何系统安装设备的情况下安装Ghost版XP.Win7/8/ ...

  7. 11月3日上午PHP练习《投票》

    1.建立数据库 表1:DiaoYanTiMu 表2:DiaoYanXuanXiang 2.页面 页面1:投票首页 <!DOCTYPE html PUBLIC "-//W3C//DTD ...

  8. 【Solr】新建core后,启动服务访问web报错 HTTP Status 503

    新建core collection2后,启动solr服务,访问solr web界面报错. HTTP Status 503 - Server is shutting down or failed to ...

  9. Hadoop-HBASE案例分析-Hadoop学习笔记<二>

    之前有幸在MOOC学院抽中小象学院hadoop体验课. 这是小象学院hadoop2.X概述第八章的笔记 主要介绍HBase,一个分布式数据库的应用案例. 案例概况: 1)时间序列数据库(OpenTSD ...

  10. C++,当类名和对象名称相同时会发生什么?

    今天突发奇想,如果类名和由这个类声明的对象标识符相同时会发生什么,然后就测试了一下.如下: #include <iostream> using namespace std; class a ...