第1小题

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.34 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------------
% X(k) is DFTs of real-valued sequence x(n)
% x(n)=A*cos(2*pi*l*n/N) n=[0:N-1]
%
% 1 x1(n) = 3cos(0.04*pi*n) n=[0:200-1]
% -------------------------------------------------------------------------------------
N = 200; l = 2;
n1 = [0:N-1];
x1 = 3*cos(2*pi*l*n1/100); figure('NumberTitle', 'off', 'Name', 'P5.34.1 x(n), N=200')
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x(n)');
title('x(n)=3cos(0.04*pi*n)'); grid on; k1 = [0:N-1];
Xk_DFT = fft(x1, N);
N1 = length(Xk_DFT); % length magXk_DFT = abs( [ Xk_DFT ] ); % DFT magnitude
angXk_DFT = angle( [Xk_DFT] )/pi; % DFT angle
realXk_DFT = real(Xk_DFT); imagXk_DFT = imag(Xk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.34.1 X(k), DFT of x(n) N=200')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of x(n)'); grid on;
subplot(2,2,3); stem(k1, angXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of x(n)'); grid on;
subplot(2,2,2); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n)'); grid on;
subplot(2,2,4); stem(k1, imagXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of x(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.34.1 real X(k), N=200')
set(gcf,'Color','white');
stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n)'); grid on;

  运行结果:

N=200个样点共包含4个周期:

序列的DFT

DFT的实部序列

由上图可知,有两条孤立谱线,位于k=L=4和k=N-L=200-4=196处,幅度值AN/2=3×200/2=300。

《DSP using MATLAB》Problem 5.34的更多相关文章

  1. 《DSP using MATLAB》Problem 8.34

    今天下了小雨,空气中泛起潮湿的味道,阴冷的感觉袭来,心情受到小小影响. 代码: hp2lpfre子函数 function [wpLP, wsLP, alpha] = hp2lpfre(wphp, ws ...

  2. 《DSP using MATLAB》Problem 7.34

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  4. 《DSP using MATLAB》Problem 7.35

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  5. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  6. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  8. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  9. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

随机推荐

  1. CCF关于NOIP2018获奖证书发放的公告

    CCF定于即日起开始受理NOIP2018获奖证书申请.凡获得NOIP2018复赛提高组和普及组一二三等奖的选手均可申请证书.本次获奖证书有电子版和纸质版两种.电子版证书免费发放,纸质版证书收取部分工本 ...

  2. [POJ3378]Crazy Thairs

    Problem 给你一个数列,让你求由五个元素组成的顺序对的个数. Solution DP:用DP[i][j]表示把第j个作为五元组中第i个的方案数 则DP[i][j]=sum{DP[k][j-1]} ...

  3. 将一个xml文件解析到一个list中

    public List<News> getListFromXml(InputStream in) { XmlPullParser parser = Xml.newPullParser(); ...

  4. Java 集成开发环境的介绍及下载

    集成开发环境(integrated development environment,JDE) 之前成功运行了Java小程序是经历了先在笔记本中编写源代码,然后通过命令行运行打开javac编译源文件, ...

  5. Intellij IDEA生成foreach或者loop 快捷键

    iter Iterate (for each..in) itin Iterate (for..in) itli Iterate over a List itar Iterate elements of ...

  6. activemq 生产消费模式,订阅发布模式不同类型数据传输

    1.项目结构 2. activemq-pom pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

  7. C++类构造函数初始化列表(转)

    构造函数初始化列表以一个冒号开始,接着是以逗号分隔的数据成员列表,每个数据成员后面跟一个放在括号中的初始化式.例如: { public:     int a;     float b;     //构 ...

  8. L290 英语中级班-3月上

    1元音饱满度 a [ei] name gamee [i:] he she mei [ai] fine likeo [ou] go homeu [ u:] use blue 2口音适应 刚开始说时,慢点 ...

  9. leetcode第40题:组合总和II

    给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candidates 中的每个数字在每个组合中只能使用一次. ...

  10. python分析nginx自定义日志

    # -*- coding:utf-8 -*- import datetimeimport re logfile = '''192.168.23.43 - 2017-12-14:00:14:41 /se ...