1、代码:

从MATLAB官方网上下载的。

%*************************************************************************%
%A code for the Downsampler%
%Author: Yashwant Marathe%
%Date:20-12-2010%
function [y ny] = dnsample(x,n,M)
%x is a sequence over indices specified by vector n,M is the downsampling factor. param=n/M;
%generates the parameter vector.This vector will decide which input samples will be present in the output. samp=fix(param)==param;
%only those output vectors corresponding to indices where samp==1 will be present in the output. y=x(samp==1);
%generates the output sequence ny=n(samp==1)/M;
%generates the indices of the output sequence end
%**************************************************************************

2、代码

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.8.2 \n\n'); banner();
%% ------------------------------------------------------------------------ n = [-50:1:50];
x = sin( 0.125 * pi * n ); M = 4; [y, m] = dnsample(x, n, M); figure('NumberTitle', 'off', 'Name', 'Problem 2.8.2')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(n, x); title('x sequence');
xlabel('n'); ylabel('x(n)') ;
grid on
subplot(2,1,2); stem(m, y); title('y sequence');
xlabel('n'); ylabel('y(m)');
grid on;

  运行结果:

3、代码

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.8.3 \n\n'); banner();
%% ------------------------------------------------------------------------ n = [-50:1:50];
x = sin( 0.5 * pi * n ); M = 4; [y, m] = dnsample(x, n, M); figure('NumberTitle', 'off', 'Name', 'Problem 2.8.3')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(n, x); title('x sequence');
xlabel('n'); ylabel('x(n)') ;
grid on
subplot(2,1,2); stem(m, y); title('y sequence');
xlabel('n'); ylabel('y(m)');
grid on;

  运行结果:

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

  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. com.sun.image.codec.jpeg在Eclipse中报错的解决办法

    在Eclipse中处理图片,需要引入两个包:import com.sun.image.codec.jpeg.JPEGCodec;import com.sun.image.codec.jpeg.JPEG ...

  2. ACM-ICPC 2017 Asia Shenyang Solution

    A: BBP Formula https://www.cnblogs.com/LzyRapx/p/7802790.html #include <bits/stdc++.h> using n ...

  3. ZW团队:IN_OUT传播模型简介

    传统媒体,网络媒体的整合推广,我曾经提出过一个:Tn-Out模式 In-Out是NBA的篮球术语,你自己百度下 传统媒体承担"IN"的角色,负责传播的深度和建立公信力 网络媒体充当 ...

  4. SQL case when 多条件查询

    基于列的逻辑表达式,其实就是CASE表达式.可以用在SELECT,UPDATE,DELETE,SET以及IN,WHERE,ORDER BY和HAVING子句之后.下面给个简单示例:

  5. react headtop title 截取

    render() { const nav = this.props.nav const text = nav && nav.length > 5 ? this.strHandle ...

  6. anaconda + tensorflow +ubuntu 超级菜鸟,大家多指正【转】

    本文转载自:https://blog.csdn.net/zzw000000/article/details/51203331 1.首先安装Anaconda 下载linux对应的anaconda版本,下 ...

  7. Spring Boot从Controller层进行单元测试

    单元测试是程序员对代码的自测,一般公司都会严格要求单元测试,这是对自己代码的负责,也是对代码的敬畏. 一般单元测试都是测试Service层,下面我将演示从Controller层进行单元测试. 无参Co ...

  8. noip 2018 D1T3 赛道修建

    noip 2018 D1T3 赛道修建 首先考虑二分答案,这时需要的就是对于一个长度求出能在树中选出来的最多的路径条数.考虑到一条路径是由一条向上的路径与一条向下的路径构成,或者仅仅是向上或向下的路径 ...

  9. Google V8 引擎 原理详解

    V8 引擎概览 V8 引擎简介 Google V8 引擎使用 C++ 代码编写,实现了 ECMAScript 规范的第五版,可以运行在所有的主流 操作系统中,甚至可以运行在移动终端 ( 基于 ARM ...

  10. .Net web 关于表单标题

    今天跟以前同事学到一个好东西,就是后台web界面表单标题展示的一个方法,新学到的一个方法...赶紧分享一下 在model 属性上加  [DisplayName("标题"), Req ...