这段时间爬山去了,山中林密荆棘多,沟谷纵横,体力增强不少。

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.3 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ------------------------------------------
% 1 x1(n)=5sin(0.1pi*n) n=[0:19], N=40
% ------------------------------------------
L = 20; n = [0:L-1]; N = 40; k = [-N/2:N/2]; % wave parameters
xn_1 = [5*sin(0.1*pi*n), zeros(1, N-L)];
Xk_1 = dfs(xn_1, N); % DFS
magXk = abs( [Xk_1(N/2+1 : N) Xk_1(1 : N/2+1)] ); % DFS magnitude
angXk = angle( [Xk_1(N/2+1 : N) Xk_1(1 : N/2+1)] )/pi; % DFS angle figure('NumberTitle', 'off', 'Name', 'P5.3 xn_1')
set(gcf,'Color','white');
stem([0:N-1], xn_1);
xlabel('n'); ylabel('x(n)');
title('xn1 sequence, N=40'); grid on; %% ------------------------------------------------------
%% DFS(k) of xn1 sequence
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.3 DFS(k) of xn_1')
set(gcf,'Color','white');
subplot(2,1,1); stem(k, 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(k, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn1, N=40'); grid on; % ------------------------------------------
% 2 x2(n)=5sin(0.1pi*n) n=[0:19], N=80
% ------------------------------------------
L = 20; n = [0:L-1]; N = 80; k = [-N/2:N/2]; % wave parameters
xn_2 = [5*sin(0.1*pi*n), zeros(1, N-L)];
Xk_2 = dfs(xn_2, N); % DFS
magXk = abs( [Xk_2(N/2+1 : N) Xk_2(1 : N/2+1)] ); % DFS magnitude
angXk = angle([Xk_2(N/2+1 : N) Xk_2(1 : N/2+1)] )/pi; % DFS angle figure('NumberTitle', 'off', 'Name', 'P5.3 xn_2')
set(gcf,'Color','white');
stem([0:N-1], xn_2);
xlabel('n'); ylabel('x(n)');
title('xn2 sequence, N=80'); grid on; %% ------------------------------------------------------
%% DFS(k) of xn2 sequence
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.3 DFS(k) of xn_2')
set(gcf,'Color','white');
subplot(2,1,1); stem(k, magXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFS magnitude of xn2, N=80'); grid on;
subplot(2,1,2); stem(k, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn2, N=80'); grid on;

  运行结果:

这两个序列的基本周期不同,但是二者非零元素值相同。x2(n)相当于在x1的末尾进行补零操作,加了40个零。

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

  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. java实现按中文首字母排序的方式

    public class ABD { public static void main(String[] args) { //Collator类是用来执行区分语言环境的String比较的,这里是选择CH ...

  2. 求1+2+……+n的和

    题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). class Solution { public ...

  3. POJ 1035 Spell checker 字符串 难度:0

    题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直 ...

  4. Oracle数据库备份策略:全备与增量备份

    一.RMAN全备份 在数据量比较小.或者数据库服务器性能很强大的情况下,可以每天进行一次全备份. 全被策略如下 1.crontab定时任务,避开业务繁忙时段 ##################### ...

  5. 主机访问虚拟机centos7的服务器

    一.虚拟机开启桥梁接 1.编辑-->虚拟网络编辑器 2.虚拟机-->设置 二.Centos的配置---关闭防火墙下的服务器接口 Centos7.0 默认使用firewall作为防火墙,这里 ...

  6. JDK的下载及配置

    下载地址,为了兼容最好安装1.8版本 jdk1.8:http://jbox.jd.com/quickshare/d2wheyazjtdccshou2dbo24roejdk1.7:http://jbox ...

  7. Alpha冲刺2

    前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/9960487.html 作业博客:https://edu.cnblogs.com/campus/ ...

  8. <容错性FaultTolerance><Hadoop><Spark>

    Overview 讨论一些常见大数据框架的容错机制 Fault Tolerance in Hadoop MapReduce Heartbeat心跳机制:如果在一定时间内没有收到心跳,则reschedu ...

  9. 初玩OpenWRT之编译TP-Link WR841N V8固件

    0x00 安装依赖 安装git以下载OpenWrt源码.安装编译工具以进行交叉编译: sudo apt-get update sudo apt-get install build-essential ...

  10. 使用grafana cli重置grafana密码

    Grafana CLIgrafana cli是grafana server自带的一个小巧的二进制工具,用来在运行grafana server的机器上执行命令.插件grafana cli工具允许你安装升 ...