代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.5 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ----------------------------------------------
% 1 x1(n)=5sin(0.1pi*n) n=[0:19], N=40
% ----------------------------------------------
L = 20; n = [0:L-1]; N = 40; %k1 = [0 : N-1]; % wave parameters xn_1 = [5*sin(0.1*pi*n), zeros(1, N-L)]; N3 = 2*length(xn_1);
xn_3 = [xn_1 xn_1]; figure('NumberTitle', 'off', 'Name', 'P5.5 xn_1 and xn_3')
set(gcf,'Color','white');
subplot(2,1,1); stem([0:N-1], xn_1);
xlabel('n'); ylabel('x(n)');
title('xn1 sequence in Problem 5.3, N=40'); grid on;
subplot(2,1,2); stem([0:N3-1], xn_3);
xlabel('n'); ylabel('x(n)');
title('xn3 sequence, N=80'); grid on; %% ------------------------------------------------------
%% DFS(k) of xn1 sequence
%% ------------------------------------------------------
k1 = [0 : length(xn_1)-1];
%k2 = [-N : N-1];
%k3 = [-N/2 : N/2];
Xk_1 = dfs(xn_1, N); % DFS
magXk = abs( [ Xk_1 ] ); % DFS magnitude
angXk = angle( [Xk_1] )/pi; % DFS angle figure('NumberTitle', 'off', 'Name', 'P5.5 DFS(k) of xn_1')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFS magnitude of xn1, N=40'); grid on;
subplot(2,1,2); stem(k1, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn1, N=40'); grid on; %% ------------------------------------------------------------
%% DFS(k) of xn3 sequence
%% ------------------------------------------------------------
k1 = [0 : N3-1];
%k2 = [-N : N-1];
%k3 = [-N3/2 : N3/2];
Xk_3 = dfs(xn_3, N3);
magXk_3 = abs( [Xk_3]);
angXk_3 = angle( [Xk_3])/pi; figure('NumberTitle', 'off', 'Name', 'P5.5 DFS(k) of xn_3')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk_3); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFS magnitude of xn3, N=80'); grid on;
subplot(2,1,2); stem(k1, angXk_3); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn3, N=80'); grid on;

  运行结果:

这里假设M=2,即原序列x1重复出现2次得到新序列x3。

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

  1. 《DSP using MATLAB》Problem 7.27

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

  2. 《DSP using MATLAB》Problem 7.26

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

  3. 《DSP using MATLAB》Problem 7.25

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

  4. 《DSP using MATLAB》Problem 7.24

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

  5. 《DSP using MATLAB》Problem 7.23

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

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

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

  9. 《DSP using MATLAB》Problem 7.13

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

  10. 《DSP using MATLAB》Problem 7.12

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

随机推荐

  1. API服务网关(Zuul)

    技术背景 前面我们通过Ribbon或Feign实现了微服务之间的调用和负载均衡,那我们的各种微服务又要如何提供给外部应用调用呢. 当然,因为是REST API接口,外部客户端直接调用各个微服务是没有问 ...

  2. day1 计算机硬件基础

    CPU包括运算符和逻辑符 储存器包括内存和硬盘 7200转的机械硬盘一般找到想要的数据需要9毫秒的时间      4+5   5毫秒的时间是磁头到磁盘轨道    4毫秒是平均开始查找想要的数据到找到的 ...

  3. POJ 2002 Squares 几何, 水题 难度: 0

    题目 http://poj.org/problem?id=2002 题意 已知平面内有1000个点,所有点的坐标量级小于20000,求这些点能组成多少个不同的正方形. 思路 如图,将坐标按照升序排列后 ...

  4. hdu3518

    题解: 后缀数组 枚举长度为k(1<=k<=len/2)的满足要求的子串个数 代码: #include<cstdio> #include<cmath> #inclu ...

  5. day9-复习学习python实例

    学习实例代码 #求1到100的和print ("##################1到100求和#################")def sum(a,b): s = 0 fo ...

  6. CSS(三)--自定义标签

    HTML代码 <body> <ul> <li>1</li> <li>2</li> </ul> </body&g ...

  7. Json使用示例

    使用Json,可以下载如下所示的6个Jar包 整个工程目录结构如下: 简单的用法: package json; import net.sf.json.JSONArray; import net.sf. ...

  8. 《Python》正则表达式

    re模块 正则表达式: 应用场景: 1.判断某一个字符串是否符合规则 (注册时:判断手机号,身份证号,邮箱格式是否正确) 2.将符合规则的内容从一个庞大的字符串体系中提取出来 (爬虫,日志分析) 什么 ...

  9. DevExpress ASP.NET Bootstrap Controls v18.2新功能详解(二)

    行业领先的.NET界面控件2018年第二次重大更新——DevExpress v18.2日前正式发布,本站将以连载的形式为大家介绍新版本新功能.本文将介绍了DevExpress ASP.NET Boot ...

  10. SharePoint online Multilingual support - Settings

    博客地址:http://blog.csdn.net/FoxDave This post will talk about how to enable sharepoint online site mul ...