代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% 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. Uboot启动流程分析(转载)

    最近一段时间一直在做uboot移植相关的工作,需要将uboot-2016-7移植到单位设计的ARMv7的处理器上.正好元旦放假三天闲来无事,有段完整的时间来整理下最近的工作成果.之前在学习uboot时 ...

  2. java实现按中文首字母排序的方式

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

  3. day3-PyCharm 断点 调试模式

    上篇学习了Python的工具选择,PyCharm的基本设置,简单的了解了下PyCharm的调试模式,今天主要学习下PyCharm的调式模式,在以后的开发中是一个非常重要的工具. [运行]和[调试]前的 ...

  4. useful links about machine learning

    机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 1) 机器学习(Machine Learning)&深度学习(Deep Lea ...

  5. [leetcode121]股票买卖 Best Time to Buy and Sell Kadane算法

    [题目] Say you have an array for which the ith element is the price of a given stock on day i. If you ...

  6. E - Mahmoud and Ehab and the bipartiteness CodeForces - 862B (dfs黑白染色)

    Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipa ...

  7. 2018-2019-2 20175224 实验三《敏捷开发与XP实验》实验报告

    一.实验报告封面 课程:Java程序设计 班级:1752班 姓名:艾星言 学号:20175224 指导教师:娄嘉鹏 实验日期:2019年4月29日 实验时间:13:45 - 15:25 实验序号:24 ...

  8. 数据分析常用的python工具和SQL语句

    select symbol, "price.*" from stocks :使用正则表达式来指定列查询 select count(*), avg(salary) from empl ...

  9. nginx的相关配置记录和总结

    前言 本文旨在对nginx的各项配置文件和参数做一个记录和总结. 原因是在配置框架和虚拟目录,web语言解析的nginx环境的时候遇到各种问题和参数,有时百度可以解决,有时直接复制粘贴,大都当时有些记 ...

  10. python scrapy 把cookie并转化为字典的形式

    在用scrapy设置cookie的时候,需要从网页上对应的页面把cookie字段复制下来,并转化为字典的形式,下面代码是对cookie的转化过程 # -*- coding: utf-8 -*- cla ...